package gudusoft.gsqlparser;

import gudusoft.gsqlparser.compiler.TContext;
import gudusoft.gsqlparser.compiler.TFrame;
import gudusoft.gsqlparser.compiler.TGlobalScope;
import gudusoft.gsqlparser.nodes.*;
import gudusoft.gsqlparser.nodes.teradata.TTeradataHelper;
import gudusoft.gsqlparser.resolver.*;
import gudusoft.gsqlparser.sqlenv.TSQLEnv;
import gudusoft.gsqlparser.stmt.*;
import gudusoft.gsqlparser.stmt.dax.TDaxEvaluateStmt;
import gudusoft.gsqlparser.stmt.dax.TDaxExprStmt;
import gudusoft.gsqlparser.stmt.greenplum.TSlashCommand;
import gudusoft.gsqlparser.stmt.mssql.TMssqlBlock;
import gudusoft.gsqlparser.stmt.mssql.TMssqlCreateProcedure;
import gudusoft.gsqlparser.stmt.mssql.TMssqlExecute;
import gudusoft.gsqlparser.stmt.mysql.TMySQLSource;
import gudusoft.gsqlparser.stmt.oracle.TPlsqlCreatePackage;
import gudusoft.gsqlparser.stmt.oracle.TSqlplusCmdStatement;
import gudusoft.gsqlparser.stmt.teradata.TTeradataBTEQCmd;
import gudusoft.gsqlparser.stmt.teradata.TTeradataFastExportCmd;
import gudusoft.gsqlparser.stmt.teradata.TTeradataFastLoadCmd;
import gudusoft.gsqlparser.stmt.teradata.TTeradataMultiLoadCmd;

import java.io.*;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.*;

public class TGSqlParser {
    private String sqlCharset;
    public static EDbVendor currentDBVendor;
    private Stack<TFrame> frameStack;
    FileInputStream streamFromSqlFile;
    InputStreamReader sqlStreamReader;
    static final int stored_procedure_nested_level = 1024;
    public String sqltext;
    public String sqlfilename;
    private BufferedInputStream sqlInputStream;
    public TSourceTokenList sourcetokenlist;
    public TStatementList sqlstatements;
    private ArrayList<TSyntaxError> syntaxErrors;
    private boolean enablePartialParsing;
    private static String userName;
    private static String machineId;
    private static String licenseKey;
    private static String licenseType;
    private static boolean licenseOK;
    private EDbVendor dbVendor;
    private String errormessage;
    private TCustomLexer flexer;
    TCustomParser fparser;
    TCustomParser fplsqlparser;
    BufferedReader finputstream;
    TCustomSqlStatement gcurrentsqlstatement;
    TCustomSqlStatement nextStmt;
    TSqlCmds sqlcmds;
    HashMap sqlpluskeywordList;
    char delimiterchar;
    String defaultDelimiterStr;
    private ITokenHandle tokenHandle;
    private IMetaDatabase metaDatabase;
    TContext globalContext;
    char curdelimiterchar;
    String userDelimiterStr;
    private boolean isSinglePLBlock;
    boolean isOracleStyleRoutine;
    TSourceToken stProcedure;
    TSourceToken stFunction;
    private TSQLEnv sqlEnv;
    private boolean onlyNeedRawParseTree;

    public void setSqlCharset(final String sqlCharset) {
        this.sqlCharset = sqlCharset;
    }

    public String getSqlCharset() {
        return this.sqlCharset;
    }

    public static EDbVendor getDBVendorByName(final String dbVendorName) {
        EDbVendor vendor;
        if (dbVendorName.contains("access")) {
            vendor = EDbVendor.dbvaccess;
        } else if (dbVendorName.contains("ansi")) {
            vendor = EDbVendor.dbvansi;
        } else if (dbVendorName.contains("bigquery")) {
            vendor = EDbVendor.dbvbigquery;
        } else if (dbVendorName.contains("couchbase")) {
            vendor = EDbVendor.dbvcouchbase;
        } else if (dbVendorName.contains("dax")) {
            vendor = EDbVendor.dbvdax;
        } else if (dbVendorName.contains("db2")) {
            vendor = EDbVendor.dbvdb2;
        } else if (dbVendorName.contains("firebird")) {
            vendor = EDbVendor.dbvfirebird;
        } else if (dbVendorName.contains("generic")) {
            vendor = EDbVendor.dbvgeneric;
        } else if (dbVendorName.contains("greenplum")) {
            vendor = EDbVendor.dbvgreenplum;
        } else if (dbVendorName.contains("hana")) {
            vendor = EDbVendor.dbvhana;
        } else if (dbVendorName.contains("hive")) {
            vendor = EDbVendor.dbvhive;
        } else if (dbVendorName.contains("impala")) {
            vendor = EDbVendor.dbvimpala;
        } else if (dbVendorName.contains("informix")) {
            vendor = EDbVendor.dbvinformix;
        } else if (dbVendorName.contains("mdx")) {
            vendor = EDbVendor.dbvmdx;
        } else if (dbVendorName.contains("mssql") || dbVendorName.contains("sqlserver")) {
            vendor = EDbVendor.dbvmssql;
        } else if (dbVendorName.contains("azuresql")) {
            vendor = EDbVendor.dbvazuresql;
        } else if (dbVendorName.contains("mysql")) {
            vendor = EDbVendor.dbvmysql;
        } else if (dbVendorName.contains("netezza")) {
            vendor = EDbVendor.dbvnetezza;
        } else if (dbVendorName.contains("odbc")) {
            vendor = EDbVendor.dbvodbc;
        } else if (dbVendorName.contains("openedge")) {
            vendor = EDbVendor.dbvopenedge;
        } else if (dbVendorName.contains("oracle")) {
            vendor = EDbVendor.dbvoracle;
        } else if (dbVendorName.contains("postgresql") || dbVendorName.contains("postgres")) {
            vendor = EDbVendor.dbvpostgresql;
        } else if (dbVendorName.contains("redshift")) {
            vendor = EDbVendor.dbvredshift;
        } else if (dbVendorName.contains("snowflake")) {
            vendor = EDbVendor.dbvsnowflake;
        } else if (dbVendorName.contains("sybase")) {
            vendor = EDbVendor.dbvsybase;
        } else if (dbVendorName.contains("teradata")) {
            vendor = EDbVendor.dbvteradata;
        } else if (dbVendorName.contains("soql")) {
            vendor = EDbVendor.dbvsoql;
        } else if (dbVendorName.contains("sparksql")) {
            vendor = EDbVendor.dbvsparksql;
        } else if (dbVendorName.contains("exasol")) {
            vendor = EDbVendor.dbvexasol;
        } else if (dbVendorName.contains("athena")) {
            vendor = EDbVendor.dbvathena;
        } else if (dbVendorName.contains("presto")) {
            vendor = EDbVendor.dbvpresto;
        } else if (dbVendorName.contains("trino")) {
            vendor = EDbVendor.dbvtrino;
        } else if (dbVendorName.contains("databricks")) {
            vendor = EDbVendor.dbvdatabricks;
        } else if (dbVendorName.contains("vertica")) {
            vendor = EDbVendor.dbvvertica;
        } else if (dbVendorName.contains("gaussdb")) {
            vendor = EDbVendor.dbvgaussdb;
        } else if (dbVendorName.contains("ansi")) {
            vendor = EDbVendor.dbvansi;
        } else {
            vendor = EDbVendor.dbvoracle;
        }
        return vendor;
    }

    public Stack<TFrame> getFrameStack() {
        if (this.frameStack == null) {
            this.frameStack = new Stack<TFrame>();
        }
        return this.frameStack;
    }

    public void setFrameStack(final Stack<TFrame> frameStack) {
        this.frameStack = frameStack;
    }

    void closeFileStream() {
        if (this.streamFromSqlFile != null) {
            try {
                this.streamFromSqlFile.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public TSourceTokenList getSourcetokenlist() {
        return this.sourcetokenlist;
    }

    public TStatementList getSqlstatements() {
        return this.sqlstatements;
    }

    public void setSqltext(final String sqltext) {
        this.sqltext = sqltext;
        this.sqlfilename = "";
        this.sqlInputStream = null;
    }

    public String getSqltext() {
        return this.sqltext;
    }

    public void setSqlfilename(final String sqlfilename) {
        this.sqlfilename = sqlfilename;
        this.sqltext = "";
        this.sqlInputStream = null;
    }

    public String getSqlfilename() {
        return this.sqlfilename;
    }

    public void setSqlInputStream(final InputStream sqlInputStream) {
        if (sqlInputStream instanceof BufferedInputStream) {
            this.sqlInputStream = (BufferedInputStream) sqlInputStream;
        } else {
            this.sqlInputStream = new BufferedInputStream(sqlInputStream);
        }
        this.sqlfilename = "";
        this.sqltext = "";
    }

    public InputStream getSqlInputStream() {
        return this.sqlInputStream;
    }

    public ArrayList<TSyntaxError> getSyntaxErrors() {
        return this.syntaxErrors;
    }

    public EDbVendor getDbVendor() {
        return this.dbVendor;
    }

    @Deprecated
    public void setEnablePartialParsing(final boolean enablePartialParsing) {
        this.enablePartialParsing = enablePartialParsing;
    }

    @Deprecated
    private boolean isEnablePartialParsing() {
        return this.enablePartialParsing;
    }

    public static String getUserName() {
        return TGSqlParser.userName;
    }

    public static String getMachineId() {
        return TGSqlParser.machineId;
    }


    public static String getLicenseType() {
        return TGSqlParser.licenseType;
    }

    public TCustomLexer getFlexer() {
        return this.flexer;
    }

    public void setTokenHandle(final ITokenHandle tokenHandle) {
        this.tokenHandle = tokenHandle;
    }

    @Deprecated
    public void setMetaDatabase(final IMetaDatabase metaDatabase) {
        this.metaDatabase = metaDatabase;
    }

    @Deprecated
    public IMetaDatabase getMetaDatabase() {
        return this.metaDatabase;
    }

    public void freeParseTable() {
        this.flexer.yystack = null;
        this.flexer.yytextbuf = null;
        this.flexer.buf = null;
    }

    public TGSqlParser(final EDbVendor pdbvendor) {
        this.sqlCharset = null;
        this.frameStack = null;
        this.streamFromSqlFile = null;
        this.sqlStreamReader = null;
        this.enablePartialParsing = false;
        this.finputstream = null;
        this.tokenHandle = null;
        this.metaDatabase = null;
        this.userDelimiterStr = "";
        this.isSinglePLBlock = false;
        this.isOracleStyleRoutine = true;
        this.stProcedure = null;
        this.stFunction = null;
        this.sqlEnv = null;
        this.onlyNeedRawParseTree = false;
        this.dbVendor = pdbvendor;
        this.sqltext = "";
        this.sqlfilename = "";
        this.delimiterchar = ';';
        this.defaultDelimiterStr = ";";
        switch (pdbvendor) {
            case dbvmssql:
            case dbvaccess:
            case dbvazuresql: {
                this.flexer = new TLexerMssql();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserMssqlSql((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                if (pdbvendor == EDbVendor.dbvazuresql) {
                    this.dbVendor = EDbVendor.dbvmssql;
                    break;
                }
                break;
            }
            case dbvsybase: {
                this.flexer = new TLexerSybase();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserSybase((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                this.enablePartialParsing = false;
                break;
            }
            case dbvinformix: {
                this.flexer = new TLexerInformix();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserInformix((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                this.enablePartialParsing = false;
                break;
            }
            case dbvoracle: {
                this.delimiterchar = '/';
                this.flexer = new TLexerOracle();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserOracleSql((TSourceTokenList) null);
                this.fplsqlparser = new TParserOraclePLSql((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                this.fplsqlparser.lexer = this.flexer;
                this.fplsqlparser.getNf().setGsqlParser(this);
                break;
            }
            case dbvdb2: {
                this.delimiterchar = '@';
                this.flexer = new TLexerDb2();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserDb2Sql((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvmysql: {
                this.delimiterchar = '$';
                this.defaultDelimiterStr = "$";
                this.flexer = new TLexerMysql();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserMysqlSql((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvteradata: {
                this.delimiterchar = '/';
                this.flexer = new TLexerTeradata();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserTeradata((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvpostgresql: {
                this.delimiterchar = '/';
                this.flexer = new TLexerPostgresql();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserPostgresql((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvredshift: {
                this.delimiterchar = '/';
                this.flexer = new TLexerRedshift();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserRedshift((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvgreenplum: {
                this.delimiterchar = '/';
                this.flexer = new TLexerGreenplum();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserGreenplum((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvmdx: {
                this.delimiterchar = ';';
                this.flexer = new TLexerMdx();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserMdx((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvnetezza: {
                this.delimiterchar = ';';
                this.flexer = new TLexerNetezza();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserNetezza((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvhive: {
                this.delimiterchar = ';';
                this.flexer = new TLexerHive();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserHive((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvimpala: {
                this.delimiterchar = ';';
                this.flexer = new TLexerImpala();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserImpala((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvhana: {
                this.delimiterchar = ';';
                this.flexer = new TLexerHana();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserHana((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvdax: {
                this.delimiterchar = ';';
                this.flexer = new TLexerDax();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserDax((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvodbc: {
                this.delimiterchar = ';';
                this.flexer = new TLexerOdbc();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserOdbc((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvvertica: {
                this.delimiterchar = ';';
                this.flexer = new TLexerVertica();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserVertica((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvopenedge: {
                this.delimiterchar = ';';
                this.flexer = new TLexerOpenedge();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserOpenedge((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvcouchbase: {
                this.delimiterchar = ';';
                this.flexer = new TLexerCouchbase();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserCouchbase((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvsnowflake: {
                this.delimiterchar = ';';
                this.flexer = new TLexerSnowflake();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserSnowflake((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvbigquery: {
                this.delimiterchar = ';';
                this.flexer = new TLexerBigquery();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserBigquery((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvansi: {
                this.delimiterchar = ';';
                this.flexer = new TLexerAnsi();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserAnsi((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvgeneric: {
                this.flexer = new TLexerMssql();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserMssqlSql((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvsoql: {
                this.delimiterchar = ';';
                this.flexer = new TLexerSoql();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserSoql((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvsparksql: {
                this.delimiterchar = ';';
                this.flexer = new TLexerSparksql();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserSparksql((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvathena: {
                this.delimiterchar = ';';
                this.flexer = new TLexerathena();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserAthena((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvpresto: {
                this.delimiterchar = ';';
                this.flexer = new TLexerPresto();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserPresto((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvtrino: {
                this.delimiterchar = ';';
                this.flexer = new TLexerPresto();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserPresto((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvdatabricks: {
                this.delimiterchar = ';';
                this.flexer = new TLexerDatabricks();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserDatabricks((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            case dbvgaussdb: {
                this.delimiterchar = ';';
                this.flexer = new TLexerGaussDB();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserGaussDB((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
            default: {
                this.flexer = new TLexerMssql();
                this.flexer.delimiterchar = this.delimiterchar;
                this.flexer.defaultDelimiterStr = this.defaultDelimiterStr;
                this.fparser = new TParserMssqlSql((TSourceTokenList) null);
                this.fparser.lexer = this.flexer;
                break;
            }
        }
        this.fparser.getNf().setGsqlParser(this);
        (this.sourcetokenlist = new TSourceTokenList()).setGsqlparser(this);
        this.sqlstatements = new TStatementList();
        this.sqlcmds = new TSqlCmds();
        this.sqlpluskeywordList = new HashMap();
        this.syntaxErrors = new ArrayList<TSyntaxError>();
        this.errormessage = "";
        TGSqlParser.currentDBVendor = this.dbVendor;
    }

    public TSelectSqlStatement parseSubquery(final String subquery) {
        return parseSubquery(this.dbVendor, subquery);
    }

    public static TSelectSqlStatement parseSubquery(final EDbVendor dbVendor, final String subquery) {
        final TSingletonParser singletonParser = TSingletonParser.getInstance();
        final TStatementList statements = singletonParser.getStmts(dbVendor, subquery);
        if (statements.size() == 0) {
            return null;
        }
        return (TSelectSqlStatement) statements.get(0);
    }

    public TExpression parseExpression(final String expr) {
        return parseExpression(this.dbVendor, expr);
    }

    public static TExpression parseExpression(final EDbVendor dbVendor, final String expr) {
        final TSingletonParser singletonParser = TSingletonParser.getInstance();
        final TStatementList statements = singletonParser.getStmts(dbVendor, "select 1 from t where " + TBaseType.newline + expr);
        if (statements.size() == 0) {
            return null;
        }
        return ((TSelectSqlStatement) statements.get(0)).getWhereClause().getCondition();
    }

    public TFunctionCall parseFunctionCall(final String newFunction) {
        return parseFunctionCall(this.dbVendor, newFunction);
    }

    public static TFunctionCall parseFunctionCall(final EDbVendor dbVendor, final String newFunction) {
        final TSingletonParser singletonParser = TSingletonParser.getInstance();
        final TStatementList statements = singletonParser.getStmts(dbVendor, "select" + TBaseType.newline + newFunction + TBaseType.newline + "from t");
        if (statements.size() == 0) {
            return null;
        }
        return statements.get(0).getResultColumnList().getResultColumn(0).getExpr().getFunctionCall();
    }

    public TObjectName parseObjectName(final String newObjectName) {
        return parseObjectName(this.dbVendor, newObjectName);
    }

    public static TObjectName parseObjectName(final EDbVendor dbVendor, final String newObjectName) {
        final TSingletonParser singletonParser = TSingletonParser.getInstance();
        final TStatementList statements = singletonParser.getStmts(dbVendor, "select" + TBaseType.newline + newObjectName + TBaseType.newline + "from t");
        if (statements.size() == 0) {
            return null;
        }
        final TExpression e = statements.get(0).getResultColumnList().getResultColumn(0).getExpr();
        TObjectName lcResult = null;
        switch (e.getExpressionType()) {
            case simple_object_name_t: {
                lcResult = e.getObjectOperand();
                break;
            }
            case simple_constant_t: {
                lcResult = new TObjectName();
                lcResult.init(e.getConstantOperand().getValueToken());
                break;
            }
        }
        return lcResult;
    }

    public TConstant parseConstant(final String newConstant) {
        return parseConstant(this.dbVendor, newConstant);
    }

    public static TConstant parseConstant(final EDbVendor dbVendor, final String newConstant) {
        final TSingletonParser singletonParser = TSingletonParser.getInstance();
        final TStatementList statements = singletonParser.getStmts(dbVendor, "select" + TBaseType.newline + newConstant + TBaseType.newline + "from t");
        if (statements.size() == 0) {
            return null;
        }
        return statements.get(0).getResultColumnList().getResultColumn(0).getExpr().getConstantOperand();
    }

    public int getErrorCount() {
        return this.syntaxErrors.size();
    }

    public String getErrormessage() {
        String s = "";
        String hint = "Syntax error";
        for (int i = 0; i < this.syntaxErrors.size(); ++i) {
            final TSyntaxError t = this.syntaxErrors.get(i);
            if (t.hint.length() > 0) {
                hint = t.hint;
            }
            s = s + hint + "(" + t.errorno + ") near: " + t.tokentext;
            s = s + "(" + t.lineNo;
            s = s + "," + t.columnNo + ", token code:" + t.tokencode + ")";
            if (i != this.syntaxErrors.size() - 1) {
                s += TBaseType.linebreak;
            }
        }
        if (this.errormessage.length() > 0) {
            s = this.errormessage + TBaseType.linebreak + s;
        }
        return s;
    }

    public int checkSyntax() {
        return this.doparse();
    }

    public int parse() {
        return this.doparse();
    }

    public void resolveDatabaseObject() {
        final TDatabaseObjectResolver databaseObjectResolver = new TDatabaseObjectResolver(this.sqlstatements, this.globalContext);
        databaseObjectResolver.resolve();
    }

    public void resolveStarColumn() {
        final TStarColumnPushDownResolver startColumnResolver = new TStarColumnPushDownResolver(this.sqlstatements, this.globalContext);
        startColumnResolver.resolve();
    }

    public void resolveRelation() {
        final TRelationResolver relationResolver = new TRelationResolver(this.sqlstatements, this.globalContext);
        relationResolver.resolve();
    }

    public void expandStarColumnAndSubQuery() {
        final TStarColumnSubQueryResolver starColumnSubQueryResolver = new TStarColumnSubQueryResolver(this.sqlstatements, this.globalContext);
        starColumnSubQueryResolver.resolve();
    }

    public void resolveAttribute() {
        final TAttributeResolver attributeResolver = new TAttributeResolver(this.sqlstatements, this.globalContext);
        attributeResolver.resolve();
    }

    public void collectMetadata() {
        final TMetadataCollector metadataCollector = new TMetadataCollector(this.sqlstatements, this.globalContext);
        metadataCollector.collect();
    }

    public int validate() {
        if (this.sqlstatements.size() == 0) {
            return 0;
        }
        final TRelationValidator relationValidate = new TRelationValidator(this.globalContext);
        for (final TCustomSqlStatement sqlStatement : this.sqlstatements) {
            sqlStatement.acceptChildren(relationValidate);
        }
        return 0;
    }

    void setdelimiterchar(final char ch) {
        this.delimiterchar = ch;
        this.flexer.delimiterchar = ch;
    }

    boolean includesqlstatementtype(final ESqlStatementType search, final ESqlStatementType[] src) {
        boolean ret = false;
        for (int i = 0; i < src.length; ++i) {
            if (src[i] == search) {
                ret = true;
                break;
            }
        }
        return ret;
    }

    private int getfileEncodingType(final BufferedInputStream fr) {
        int ret = 0;
        try {
            final byte[] bom = new byte[4];
            fr.mark(bom.length + 1);
            fr.read(bom, 0, bom.length);
            if ((bom[0] == -1 && bom[1] == -2) || (bom[0] == -2 && bom[1] == -1)) {
                ret = 1;
                if ((bom[2] == -1 && bom[3] == -2) || (bom[2] == -2 && bom[3] == -1)) {
                    ret = 2;
                }
            } else if (bom[0] == -17 && bom[1] == -69 && bom[2] == -65) {
                ret = 3;
            }
            fr.reset();
        } catch (FileNotFoundException ex) {
        } catch (IOException ex2) {
        }
        return ret;
    }

    private int getfileEncodingType(final String fn) {
        int ret = 0;
        try {
            final FileInputStream fr = new FileInputStream(this.sqlfilename);
            ret = this.getfileEncodingType(new BufferedInputStream(fr));
            fr.close();
        } catch (FileNotFoundException ex) {
        } catch (IOException ex2) {
        }
        return ret;
    }

    int readsql() {
        int ret = 0;
        this.syntaxErrors.clear();
        TGSqlParser.licenseType = "dist";
        TGSqlParser.userName = "dist";
        try {
            if (this.finputstream != null) {
                this.finputstream.close();
            }
            if (this.flexer == null) {
                ret = -1;
                this.errormessage = "requested database not supported:" + this.dbVendor.toString();
                return ret;
            }
            if (this.flexer.yyinput != null) {
                this.flexer.yyinput.close();
            }
        } catch (IOException e3) {
            ret = -1;
            this.errormessage = "requested database not supported";
        }
        if (this.sqltext.length() > 0) {
            this.finputstream = new BufferedReader(new StringReader(this.sqltext));
        } else if (this.sqlfilename.length() > 0) {
            try {
                final int encodingtype = this.getfileEncodingType(this.sqlfilename);
                this.streamFromSqlFile = new FileInputStream(this.sqlfilename);
                if (encodingtype == 1) {
                    this.sqlStreamReader = new InputStreamReader(this.streamFromSqlFile, "UTF-16");
                } else if (encodingtype == 2) {
                    this.sqlStreamReader = new InputStreamReader(this.streamFromSqlFile, "UTF-32");
                } else if (encodingtype == 3) {
                    this.sqlStreamReader = new InputStreamReader(this.streamFromSqlFile, "UTF-8");
                } else {
                    if (this.sqlCharset == null) {
                        this.sqlCharset = Charset.defaultCharset().name();
                    }
                    this.sqlStreamReader = new InputStreamReader(this.streamFromSqlFile, this.sqlCharset);
                }
                this.finputstream = new BufferedReader(this.sqlStreamReader);
                if (encodingtype == 3) {
                    this.finputstream.skip(1L);
                }
                final File file = new File(this.sqlfilename);
                if (!file.exists() || !file.isFile()) {
                    ret = -1;
                    this.errormessage = "not a valid sql file.";
                }
            } catch (FileNotFoundException e) {
                ret = -1;
                this.errormessage = e.toString();
            } catch (UnsupportedEncodingException e2) {
                e2.printStackTrace();
            } catch (IOException e3) {
                e3.printStackTrace();
            }
        } else if (this.sqlInputStream != null) {
            final int encodingtype = this.getfileEncodingType(this.sqlInputStream);
            final InputStream fr = this.sqlInputStream;
            InputStreamReader isr = null;
            try {
                if (encodingtype == 1) {
                    isr = new InputStreamReader(fr, "UTF-16");
                } else if (encodingtype == 2) {
                    isr = new InputStreamReader(fr, "UTF-32");
                } else if (encodingtype == 3) {
                    isr = new InputStreamReader(fr, "UTF-8");
                } else {
                    if (this.sqlCharset == null) {
                        this.sqlCharset = Charset.defaultCharset().name();
                    }
                    isr = new InputStreamReader(fr, this.sqlCharset);
                }
                this.finputstream = new BufferedReader(isr);
                if (encodingtype == 3) {
                    this.finputstream.skip(1L);
                }
            } catch (FileNotFoundException e4) {
                ret = -1;
                this.errormessage = e4.toString();
            } catch (UnsupportedEncodingException e5) {
                e5.printStackTrace();
            } catch (IOException e6) {
                e6.printStackTrace();
            }
        }
        if (this.finputstream == null) {
            ret = -1;
        }
        if (ret == 0) {
            this.flexer.yyinput = this.finputstream;
            this.flexer.setSqlCharset(this.sqlCharset);
        }
        this.sourcetokenlist.clear();
        this.sourcetokenlist.curpos = -1;
        return ret;
    }

    TSourceToken getanewsourcetoken() {
        TSourceToken pst = null;

        while (true) {
            pst = new TSourceToken("");
            if (this.flexer.yylexwrap(pst) == 0) {
                pst = null;
                break;
            }

            pst.setDbvendor(this.dbVendor);
            pst.tokenstatus = ETokenStatus.tsoriginal;
            if (pst.tokentype == ETokenType.ttreturn) {
                pst.astext = this.towinlinebreak(pst.astext);
            }

            TSourceToken prevst;
            if (pst.tokentype == ETokenType.ttwhitespace && this.sourcetokenlist.curpos >= 0) {
                prevst = this.sourcetokenlist.get(this.sourcetokenlist.curpos);
                if (prevst.tokentype == ETokenType.ttreturn) {
                    prevst.astext = prevst.astext + pst.astext;
                    continue;
                }
            }

            if (pst.tokentype != ETokenType.ttreturn || this.sourcetokenlist.curpos < 0) {
                break;
            }

            prevst = this.sourcetokenlist.get(this.sourcetokenlist.curpos);
            if (prevst.tokentype != ETokenType.ttreturn) {
                if (prevst.tokentype == ETokenType.ttwhitespace) {
                }
                break;
            }

            prevst.astext = prevst.astext + pst.astext;
        }

        if (pst != null) {
            pst.container = this.sourcetokenlist;
            ++this.sourcetokenlist.curpos;
            pst.posinlist = this.sourcetokenlist.curpos;
            if (this.tokenHandle != null) {
                this.tokenHandle.processToken(pst);
            }
        }

        return pst;
    }

    String towinlinebreak(final String s) {
        return s;
    }

    void checkconstarinttoken(final TSourceToken lcprevtoken) {
        final TSourceTokenList lcStList = lcprevtoken.container;
        if (TBaseType.assigned(lcStList)) {
            final TSourceToken lcPPToken = lcStList.nextsolidtoken(lcprevtoken.posinlist, -2, false);
            if (TBaseType.assigned(lcPPToken) && lcPPToken.tokencode == this.flexer.getkeywordvalue("constraint")) {
                lcPPToken.tokencode = 298;
            }
        }
    }

    TSourceToken getprevtoken(final TSourceToken ptoken) {
        final TSourceTokenList lcstlist = ptoken.container;
        if (!TBaseType.assigned(lcstlist) || ptoken.posinlist <= 0 || lcstlist.size() <= ptoken.posinlist - 1) {
            return null;
        }
        if (lcstlist.get(ptoken.posinlist - 1).tokentype != ETokenType.ttwhitespace && lcstlist.get(ptoken.posinlist - 1).tokentype != ETokenType.ttreturn && lcstlist.get(ptoken.posinlist - 1).tokentype != ETokenType.ttsimplecomment && lcstlist.get(ptoken.posinlist - 1).tokentype != ETokenType.ttbracketedcomment) {
            return lcstlist.get(ptoken.posinlist - 1);
        }
        return lcstlist.nextsolidtoken(ptoken.posinlist - 1, -1, false);
    }

    void doinformixtexttotokenlist() {
        TSourceToken lcprevtoken = null;
        int lcsteps = 0;
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        int yychar = asourcetoken.tokencode;
        boolean lcinopenrowset = false;
        int lcnested = 0;
        while (yychar > 0) {
            if (asourcetoken.tokencode == 464) {
                lcinopenrowset = true;
                lcnested = 0;
            } else if (asourcetoken.tokentype == ETokenType.ttleftparenthesis) {
                if (lcsteps > 0 && TBaseType.assigned(lcprevtoken)) {
                    if (lcprevtoken.tokencode == 513) {
                        lcprevtoken.tokencode = 299;
                    } else if (lcprevtoken.tokencode == 516) {
                        lcprevtoken.tokencode = 297;
                    } else if (lcprevtoken.tokencode == 514) {
                        lcprevtoken.tokencode = 300;
                    } else if (lcprevtoken.tokencode == 338) {
                        lcprevtoken.tokencode = 295;
                    }
                    lcprevtoken = null;
                    lcsteps = 0;
                }
                if (lcinopenrowset) {
                    ++lcnested;
                }
            } else if (asourcetoken.tokentype == ETokenType.ttrightparenthesis) {
                if (lcinopenrowset) {
                    if (lcnested > 0) {
                        --lcnested;
                    }
                    if (lcnested == 0) {
                        lcinopenrowset = false;
                    }
                }
            } else if (asourcetoken.tokentype == ETokenType.ttsemicolon) {
                if (lcinopenrowset) {
                    asourcetoken.tokentype = ETokenType.ttsemicolon2;
                } else {
                    TSourceToken lctoken2 = asourcetoken.searchToken(351, -1);
                    if (lctoken2 != null) {
                        asourcetoken.tokencode = 531;
                        asourcetoken.tokentype = ETokenType.ttsemicolon3;
                    } else {
                        lctoken2 = asourcetoken.searchToken(456, -1);
                        if (lctoken2 == null) {
                            lctoken2 = asourcetoken.searchToken(462, -1);
                        }
                        if (lctoken2 != null) {
                            final TSourceToken lctoken3 = asourcetoken.searchToken(351, -2);
                            if (lctoken3 != null) {
                                asourcetoken.tokencode = 531;
                                asourcetoken.tokentype = ETokenType.ttsemicolon3;
                            }
                        }
                    }
                }
            } else if (asourcetoken.tokentype == ETokenType.ttperiod) {
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (TBaseType.assigned(lctoken4) && lctoken4.tokencode == 463) {
                    lctoken4.tokencode = 264;
                    lctoken4.tokentype = ETokenType.ttidentifier;
                }
            } else if (asourcetoken.tokencode == 308) {
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (TBaseType.assigned(lctoken4) && lctoken4.tokencode == 473) {
                    lctoken4.tokencode = 296;
                }
            } else if (asourcetoken.tokencode == 512) {
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (TBaseType.assigned(lctoken4) && lctoken4.tokencode == 481) {
                    lctoken4.tokencode = 537;
                }
            } else if (asourcetoken.tokencode == 463) {
                boolean iskeywordgo = true;
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (TBaseType.assigned(lctoken4) && lctoken4.lineNo == asourcetoken.lineNo) {
                    iskeywordgo = false;
                }
                if (iskeywordgo) {
                    lcinopenrowset = false;
                    lcnested = 0;
                    lcprevtoken = asourcetoken;
                } else {
                    asourcetoken.tokencode = 264;
                    asourcetoken.tokentype = ETokenType.ttidentifier;
                }
            } else if (asourcetoken.tokencode == 513) {
                lcsteps = 2;
                lcprevtoken = asourcetoken;
            } else if (asourcetoken.tokencode == 516) {
                lcsteps = 2;
                lcprevtoken = asourcetoken;
            } else if (asourcetoken.tokencode == 514) {
                lcsteps = 1;
                lcprevtoken = asourcetoken;
            } else if (asourcetoken.issolidtoken() && lcsteps > 0 && !TBaseType.mysametext("clustered", asourcetoken.astext) && !TBaseType.mysametext("nonclustered", asourcetoken.astext)) {
                --lcsteps;
            }
            this.sourcetokenlist.add(asourcetoken);
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken != null) {
                yychar = asourcetoken.tokencode;
            } else {
                yychar = 0;
            }
        }
    }

    void domssqlsqltexttotokenlist() {
        TSourceToken lcprevtoken = null;
        int lcsteps = 0;
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        int yychar = asourcetoken.tokencode;
        boolean lcinopenrowset = false;
        int lcnested = 0;
        while (yychar > 0) {
            if (asourcetoken.tokencode == 464) {
                lcinopenrowset = true;
                lcnested = 0;
            } else if (asourcetoken.tokentype == ETokenType.ttleftparenthesis) {
                if (lcsteps > 0 && TBaseType.assigned(lcprevtoken)) {
                    if (lcprevtoken.tokencode == 513) {
                        lcprevtoken.tokencode = 299;
                        this.checkconstarinttoken(lcprevtoken);
                    } else if (lcprevtoken.tokencode == 516) {
                        lcprevtoken.tokencode = 297;
                        this.checkconstarinttoken(lcprevtoken);
                    } else if (lcprevtoken.tokencode == 514) {
                        lcprevtoken.tokencode = 300;
                        this.checkconstarinttoken(lcprevtoken);
                    }
                    lcprevtoken = null;
                    lcsteps = 0;
                }
                if (lcinopenrowset) {
                    ++lcnested;
                }
            } else if (asourcetoken.tokentype == ETokenType.ttrightparenthesis) {
                if (lcinopenrowset) {
                    if (lcnested > 0) {
                        --lcnested;
                    }
                    if (lcnested == 0) {
                        lcinopenrowset = false;
                    }
                }
            } else if (asourcetoken.tokentype == ETokenType.ttsemicolon) {
                if (lcinopenrowset) {
                    asourcetoken.tokentype = ETokenType.ttsemicolon2;
                } else {
                    TSourceToken lctoken2 = asourcetoken.searchToken(351, -1);
                    if (lctoken2 != null) {
                        asourcetoken.tokencode = 531;
                        asourcetoken.tokentype = ETokenType.ttsemicolon3;
                    } else {
                        lctoken2 = asourcetoken.searchToken(456, -1);
                        if (lctoken2 == null) {
                            lctoken2 = asourcetoken.searchToken(462, -1);
                        }
                        if (lctoken2 != null) {
                            final TSourceToken lctoken3 = asourcetoken.searchToken(351, -2);
                            if (lctoken3 != null) {
                                asourcetoken.tokencode = 531;
                                asourcetoken.tokentype = ETokenType.ttsemicolon3;
                            }
                        }
                    }
                }
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (lctoken4 != null && lctoken4.tokentype == ETokenType.ttsemicolon) {
                    asourcetoken.tokencode = 259;
                }
            } else if (asourcetoken.tokentype == ETokenType.ttperiod) {
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (TBaseType.assigned(lctoken4) && lctoken4.tokencode == 463) {
                    lctoken4.tokencode = 264;
                    lctoken4.tokentype = ETokenType.ttidentifier;
                }
            } else if (asourcetoken.tokencode == 308) {
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (TBaseType.assigned(lctoken4) && lctoken4.tokencode == 473) {
                    lctoken4.tokencode = 296;
                }
            } else if (asourcetoken.tokencode == 332) {
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (TBaseType.assigned(lctoken4) && lctoken4.tokencode == 572) {
                    lctoken4.tokencode = 573;
                }
            } else if (asourcetoken.tokencode == 574) {
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (TBaseType.assigned(lctoken4) && lctoken4.tokencode == 314) {
                    asourcetoken.tokencode = 575;
                }
            } else if (asourcetoken.tokencode == 463) {
                boolean iskeywordgo = true;
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (TBaseType.assigned(lctoken4) && lctoken4.lineNo == asourcetoken.lineNo && lctoken4.tokencode != 59) {
                    iskeywordgo = false;
                }
                if (iskeywordgo) {
                    lcinopenrowset = false;
                    lcnested = 0;
                    lcprevtoken = asourcetoken;
                } else {
                    asourcetoken.tokencode = 264;
                    asourcetoken.tokentype = ETokenType.ttidentifier;
                }
            } else if (asourcetoken.tokencode == 513) {
                lcsteps = 2;
                lcprevtoken = asourcetoken;
            } else if (asourcetoken.tokencode == 516) {
                lcsteps = 2;
                lcprevtoken = asourcetoken;
            } else if (asourcetoken.tokencode == 514) {
                lcsteps = 1;
                lcprevtoken = asourcetoken;
            } else if (asourcetoken.issolidtoken() && lcsteps > 0 && !TBaseType.mysametext("clustered", asourcetoken.astext) && !TBaseType.mysametext("nonclustered", asourcetoken.astext) && !TBaseType.mysametext("hash", asourcetoken.astext)) {
                --lcsteps;
            }
            this.sourcetokenlist.add(asourcetoken);
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken != null) {
                yychar = asourcetoken.tokencode;
            } else {
                yychar = 0;
            }
        }
    }

    void dosybasesqltexttotokenlist() {
        TSourceToken lcprevtoken = null;
        int lcsteps = 0;
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        int yychar = asourcetoken.tokencode;
        boolean lcinopenrowset = false;
        int lcnested = 0;
        while (yychar > 0) {
            if (asourcetoken.tokencode == 464) {
                lcinopenrowset = true;
                lcnested = 0;
            } else if (asourcetoken.tokentype == ETokenType.ttleftparenthesis) {
                if (lcsteps > 0 && TBaseType.assigned(lcprevtoken)) {
                    if (lcprevtoken.tokencode == 513) {
                        lcprevtoken.tokencode = 299;
                        this.checkconstarinttoken(lcprevtoken);
                    } else if (lcprevtoken.tokencode == 516) {
                        lcprevtoken.tokencode = 297;
                        this.checkconstarinttoken(lcprevtoken);
                    } else if (lcprevtoken.tokencode == 514) {
                        lcprevtoken.tokencode = 300;
                        this.checkconstarinttoken(lcprevtoken);
                    }
                    lcprevtoken = null;
                    lcsteps = 0;
                }
                if (lcinopenrowset) {
                    ++lcnested;
                }
            } else if (asourcetoken.tokentype == ETokenType.ttrightparenthesis) {
                if (lcinopenrowset) {
                    if (lcnested > 0) {
                        --lcnested;
                    }
                    if (lcnested == 0) {
                        lcinopenrowset = false;
                    }
                }
            } else if (asourcetoken.tokentype == ETokenType.ttsemicolon) {
                if (lcinopenrowset) {
                    asourcetoken.tokentype = ETokenType.ttsemicolon2;
                } else {
                    TSourceToken lctoken2 = asourcetoken.searchToken(351, -1);
                    if (lctoken2 != null) {
                        asourcetoken.tokencode = 531;
                        asourcetoken.tokentype = ETokenType.ttsemicolon3;
                    } else {
                        lctoken2 = asourcetoken.searchToken(456, -1);
                        if (lctoken2 == null) {
                            lctoken2 = asourcetoken.searchToken(462, -1);
                        }
                        if (lctoken2 != null) {
                            final TSourceToken lctoken3 = asourcetoken.searchToken(351, -2);
                            if (lctoken3 != null) {
                                asourcetoken.tokencode = 531;
                                asourcetoken.tokentype = ETokenType.ttsemicolon3;
                            }
                        }
                    }
                }
            } else if (asourcetoken.tokentype == ETokenType.ttperiod) {
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (TBaseType.assigned(lctoken4) && lctoken4.tokencode == 463) {
                    lctoken4.tokencode = 264;
                    lctoken4.tokentype = ETokenType.ttidentifier;
                }
            } else if (asourcetoken.tokencode == 308) {
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (TBaseType.assigned(lctoken4) && lctoken4.tokencode == 473) {
                    lctoken4.tokencode = 296;
                }
            } else if (asourcetoken.tokencode == 560) {
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (TBaseType.assigned(lctoken4) && lctoken4.tokencode == 559) {
                    lctoken4.tokencode = 287;
                }
            } else if (asourcetoken.tokencode == 304) {
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (TBaseType.assigned(lctoken4) && (lctoken4.tokencode == 321 || lctoken4.tokencode == 319 || lctoken4.tokencode == 320 || lctoken4.tokencode == 305)) {
                    asourcetoken.tokencode = 288;
                }
            } else if (asourcetoken.tokencode == 463) {
                boolean iskeywordgo = true;
                final TSourceToken lctoken4 = this.getprevtoken(asourcetoken);
                if (TBaseType.assigned(lctoken4) && lctoken4.lineNo == asourcetoken.lineNo) {
                    iskeywordgo = false;
                }
                if (iskeywordgo) {
                    lcinopenrowset = false;
                    lcnested = 0;
                    lcprevtoken = asourcetoken;
                } else {
                    asourcetoken.tokencode = 264;
                    asourcetoken.tokentype = ETokenType.ttidentifier;
                }
            } else if (asourcetoken.tokencode == 513) {
                lcsteps = 2;
                lcprevtoken = asourcetoken;
            } else if (asourcetoken.tokencode == 516) {
                lcsteps = 2;
                lcprevtoken = asourcetoken;
            } else if (asourcetoken.tokencode == 514) {
                lcsteps = 1;
                lcprevtoken = asourcetoken;
            } else if (asourcetoken.issolidtoken() && lcsteps > 0 && !TBaseType.mysametext("clustered", asourcetoken.astext) && !TBaseType.mysametext("nonclustered", asourcetoken.astext)) {
                --lcsteps;
            }
            this.sourcetokenlist.add(asourcetoken);
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken != null) {
                yychar = asourcetoken.tokencode;
            } else {
                yychar = 0;
            }
        }
    }

    boolean IsValidPlaceForDivToSqlplusCmd(final TSourceTokenList pstlist, final int pPos) {
        boolean ret = false;
        if (pPos <= 0 || pPos > pstlist.size() - 1) {
            return ret;
        }
        final TSourceToken lcst = pstlist.get(pPos - 1);
        if (lcst.tokentype != ETokenType.ttreturn) {
            return ret;
        }
        if (lcst.astext.charAt(lcst.astext.length() - 1) != ' ') {
            ret = true;
        }
        return ret;
    }

    boolean isvalidsqlpluscmdInPostgresql(final String astr) {
        return false;
    }

    TSourceToken getprevsolidtoken(final TSourceToken ptoken) {
        TSourceToken ret = null;
        final TSourceTokenList lctokenlist = ptoken.container;
        if (lctokenlist != null && ptoken.posinlist > 0 && lctokenlist.size() > ptoken.posinlist - 1) {
            if (lctokenlist.get(ptoken.posinlist - 1).tokentype != ETokenType.ttwhitespace && lctokenlist.get(ptoken.posinlist - 1).tokentype != ETokenType.ttreturn && lctokenlist.get(ptoken.posinlist - 1).tokentype != ETokenType.ttsimplecomment && lctokenlist.get(ptoken.posinlist - 1).tokentype != ETokenType.ttbracketedcomment) {
                ret = lctokenlist.get(ptoken.posinlist - 1);
            } else {
                ret = lctokenlist.nextsolidtoken(ptoken.posinlist - 1, -1, false);
            }
        }
        return ret;
    }

    void doredshifttexttotokenlist() {
        boolean insqlpluscmd = false;
        boolean isvalidplace = true;
        boolean waitingreturnforfloatdiv = false;
        boolean waitingreturnforsemicolon = false;
        boolean continuesqlplusatnewline = false;
        TSourceToken lct = null;
        final TSourceToken prevst = null;
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        int yychar = asourcetoken.tokencode;
        while (yychar > 0) {
            this.sourcetokenlist.add(asourcetoken);
            switch (yychar) {
                case 257:
                case 258:
                case 259: {
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        break;
                    }
                    break;
                }
                case 260: {
                    if (insqlpluscmd) {
                        insqlpluscmd = false;
                        isvalidplace = true;
                        if (continuesqlplusatnewline) {
                            insqlpluscmd = true;
                            isvalidplace = false;
                            asourcetoken.insqlpluscmd = true;
                        }
                    }
                    if (waitingreturnforsemicolon) {
                        isvalidplace = true;
                    }
                    if (waitingreturnforfloatdiv) {
                        isvalidplace = true;
                        lct.tokencode = 273;
                        if (lct.tokentype != ETokenType.ttslash) {
                            lct.tokentype = ETokenType.ttsqlpluscmd;
                        }
                    }
                    this.flexer.insqlpluscmd = insqlpluscmd;
                    break;
                }
                default: {
                    continuesqlplusatnewline = false;
                    waitingreturnforsemicolon = false;
                    waitingreturnforfloatdiv = false;
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        if (asourcetoken.astext.equalsIgnoreCase("-")) {
                            continuesqlplusatnewline = true;
                        }
                    } else {
                        if (asourcetoken.tokentype == ETokenType.ttsemicolon) {
                            waitingreturnforsemicolon = true;
                        }
                        if (asourcetoken.tokentype == ETokenType.ttslash && (isvalidplace || this.IsValidPlaceForDivToSqlplusCmd(this.sourcetokenlist, asourcetoken.posinlist))) {
                            lct = asourcetoken;
                            waitingreturnforfloatdiv = true;
                        }
                        if (isvalidplace && this.isvalidsqlpluscmdInPostgresql(asourcetoken.astext)) {
                            asourcetoken.tokencode = 273;
                            if (asourcetoken.tokentype != ETokenType.ttslash) {
                                asourcetoken.tokentype = ETokenType.ttsqlpluscmd;
                            }
                            insqlpluscmd = true;
                            this.flexer.insqlpluscmd = insqlpluscmd;
                        }
                    }
                    isvalidplace = false;
                    if (asourcetoken.tokencode != 534) {
                        break;
                    }
                    final TSourceToken stPercent = asourcetoken.searchToken(37, -1);
                    if (stPercent != null) {
                        stPercent.tokencode = 296;
                        break;
                    }
                    break;
                }
            }
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken != null) {
                yychar = asourcetoken.tokencode;
            } else {
                yychar = 0;
                if (waitingreturnforfloatdiv) {
                    lct.tokencode = 273;
                    if (lct.tokentype != ETokenType.ttslash) {
                        lct.tokentype = ETokenType.ttsqlpluscmd;
                    }
                }
            }
            if (yychar == 0 && prevst != null) {
                continue;
            }
        }
    }

    void doansitexttotokenlist() {
        this.dodb2sqltexttotokenlist();
    }

    void dogaussdbtexttotokenlist() {
        boolean insqlpluscmd = false;
        boolean isvalidplace = true;
        boolean waitingreturnforfloatdiv = false;
        boolean waitingreturnforsemicolon = false;
        boolean continuesqlplusatnewline = false;
        TSourceToken lct = null;
        TSourceToken prevst = null;
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        int yychar = asourcetoken.tokencode;
        while (yychar > 0) {
            this.sourcetokenlist.add(asourcetoken);
            switch (yychar) {
                case 257:
                case 258:
                case 259: {
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        break;
                    }
                    break;
                }
                case 260: {
                    if (insqlpluscmd) {
                        insqlpluscmd = false;
                        isvalidplace = true;
                        if (continuesqlplusatnewline) {
                            insqlpluscmd = true;
                            isvalidplace = false;
                            asourcetoken.insqlpluscmd = true;
                        }
                    }
                    if (waitingreturnforsemicolon) {
                        isvalidplace = true;
                    }
                    if (waitingreturnforfloatdiv) {
                        isvalidplace = true;
                        lct.tokencode = 273;
                        if (lct.tokentype != ETokenType.ttslash) {
                            lct.tokentype = ETokenType.ttsqlpluscmd;
                        }
                    }
                    this.flexer.insqlpluscmd = insqlpluscmd;
                    break;
                }
                default: {
                    continuesqlplusatnewline = false;
                    waitingreturnforsemicolon = false;
                    waitingreturnforfloatdiv = false;
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        if (asourcetoken.astext.equalsIgnoreCase("-")) {
                            continuesqlplusatnewline = true;
                        }
                    } else {
                        if (asourcetoken.tokentype == ETokenType.ttsemicolon) {
                            waitingreturnforsemicolon = true;
                        }
                        if (asourcetoken.tokentype == ETokenType.ttslash && (isvalidplace || this.IsValidPlaceForDivToSqlplusCmd(this.sourcetokenlist, asourcetoken.posinlist))) {
                            lct = asourcetoken;
                            waitingreturnforfloatdiv = true;
                        }
                        if (isvalidplace && this.isvalidsqlpluscmdInPostgresql(asourcetoken.astext)) {
                            asourcetoken.tokencode = 273;
                            if (asourcetoken.tokentype != ETokenType.ttslash) {
                                asourcetoken.tokentype = ETokenType.ttsqlpluscmd;
                            }
                            insqlpluscmd = true;
                            this.flexer.insqlpluscmd = insqlpluscmd;
                        }
                    }
                    isvalidplace = false;
                    if (prevst != null) {
                        if (prevst.tokencode == 345 && asourcetoken.tokencode != this.flexer.getkeywordvalue("JOIN")) {
                            prevst.tokencode = 264;
                        }
                        if (prevst.tokencode == 321 && asourcetoken.tokencode == this.flexer.getkeywordvalue("DEFERRABLE")) {
                            prevst.tokencode = this.flexer.getkeywordvalue("NOT_DEFERRABLE");
                        }
                    }
                    if (asourcetoken.tokencode == 345) {
                        prevst = asourcetoken;
                    } else if (asourcetoken.tokencode == 321) {
                        prevst = asourcetoken;
                    } else {
                        prevst = null;
                    }
                    if (asourcetoken.tokencode == this.flexer.getkeywordvalue("DIRECT_LOAD") || asourcetoken.tokencode == this.flexer.getkeywordvalue("ALL")) {
                        final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                        if (lcprevst != null && lcprevst.tokencode == 306) {
                            lcprevst.tokencode = 285;
                        }
                    }
                    if (asourcetoken.tokencode == 534) {
                        final TSourceToken stKeep = asourcetoken.searchToken(532, -2);
                        if (stKeep != null) {
                            stKeep.tokencode = 533;
                        }
                    }
                    if (asourcetoken.tokencode == 548 || asourcetoken.tokencode == 625) {
                        final TSourceToken stPercent = asourcetoken.searchToken(37, -1);
                        if (stPercent != null) {
                            stPercent.tokencode = 296;
                        }
                    }
                    if (asourcetoken.tokencode == 298) {
                        final TSourceToken stPercent = asourcetoken.searchToken(61, -1);
                        if (stPercent != null) {
                            asourcetoken.tokencode = 264;
                        }
                    }
                    if (asourcetoken.tokencode != 304) {
                        break;
                    }
                    final TSourceToken stDo = asourcetoken.searchToken(501, -1);
                    if (stDo != null) {
                        asourcetoken.tokencode = 551;
                        break;
                    }
                    break;
                }
            }
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken != null) {
                yychar = asourcetoken.tokencode;
            } else {
                yychar = 0;
                if (waitingreturnforfloatdiv) {
                    lct.tokencode = 273;
                    if (lct.tokentype != ETokenType.ttslash) {
                        lct.tokentype = ETokenType.ttsqlpluscmd;
                    }
                }
            }
            if (yychar == 0 && prevst != null && prevst.tokencode == 345) {
                prevst.tokencode = 264;
            }
        }
    }

    void dopostgresqltexttotokenlist() {
        boolean insqlpluscmd = false;
        boolean isvalidplace = true;
        boolean waitingreturnforfloatdiv = false;
        boolean waitingreturnforsemicolon = false;
        boolean continuesqlplusatnewline = false;
        TSourceToken lct = null;
        TSourceToken prevst = null;
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        int yychar = asourcetoken.tokencode;
        while (yychar > 0) {
            this.sourcetokenlist.add(asourcetoken);
            switch (yychar) {
                case 257:
                case 258:
                case 259: {
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        break;
                    }
                    break;
                }
                case 260: {
                    if (insqlpluscmd) {
                        insqlpluscmd = false;
                        isvalidplace = true;
                        if (continuesqlplusatnewline) {
                            insqlpluscmd = true;
                            isvalidplace = false;
                            asourcetoken.insqlpluscmd = true;
                        }
                    }
                    if (waitingreturnforsemicolon) {
                        isvalidplace = true;
                    }
                    if (waitingreturnforfloatdiv) {
                        isvalidplace = true;
                        lct.tokencode = 273;
                        if (lct.tokentype != ETokenType.ttslash) {
                            lct.tokentype = ETokenType.ttsqlpluscmd;
                        }
                    }
                    this.flexer.insqlpluscmd = insqlpluscmd;
                    break;
                }
                default: {
                    continuesqlplusatnewline = false;
                    waitingreturnforsemicolon = false;
                    waitingreturnforfloatdiv = false;
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        if (asourcetoken.astext.equalsIgnoreCase("-")) {
                            continuesqlplusatnewline = true;
                        }
                    } else {
                        if (asourcetoken.tokentype == ETokenType.ttsemicolon) {
                            waitingreturnforsemicolon = true;
                        }
                        if (asourcetoken.tokentype == ETokenType.ttslash && (isvalidplace || this.IsValidPlaceForDivToSqlplusCmd(this.sourcetokenlist, asourcetoken.posinlist))) {
                            lct = asourcetoken;
                            waitingreturnforfloatdiv = true;
                        }
                        if (isvalidplace && this.isvalidsqlpluscmdInPostgresql(asourcetoken.astext)) {
                            asourcetoken.tokencode = 273;
                            if (asourcetoken.tokentype != ETokenType.ttslash) {
                                asourcetoken.tokentype = ETokenType.ttsqlpluscmd;
                            }
                            insqlpluscmd = true;
                            this.flexer.insqlpluscmd = insqlpluscmd;
                        }
                    }
                    isvalidplace = false;
                    if (prevst != null) {
                        if (prevst.tokencode == 345 && asourcetoken.tokencode != this.flexer.getkeywordvalue("JOIN")) {
                            prevst.tokencode = 264;
                        }
                        if (prevst.tokencode == 321 && asourcetoken.tokencode == this.flexer.getkeywordvalue("DEFERRABLE")) {
                            prevst.tokencode = this.flexer.getkeywordvalue("NOT_DEFERRABLE");
                        }
                    }
                    if (asourcetoken.tokencode == 345) {
                        prevst = asourcetoken;
                    } else if (asourcetoken.tokencode == 321) {
                        prevst = asourcetoken;
                    } else {
                        prevst = null;
                    }
                    if (asourcetoken.tokencode == this.flexer.getkeywordvalue("DIRECT_LOAD") || asourcetoken.tokencode == this.flexer.getkeywordvalue("ALL")) {
                        final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                        if (lcprevst != null && lcprevst.tokencode == 306) {
                            lcprevst.tokencode = 285;
                        }
                    }
                    if (asourcetoken.tokencode == 534) {
                        final TSourceToken stKeep = asourcetoken.searchToken(532, -2);
                        if (stKeep != null) {
                            stKeep.tokencode = 533;
                        }
                    }
                    if (asourcetoken.tokencode == 548 || asourcetoken.tokencode == 625) {
                        final TSourceToken stPercent = asourcetoken.searchToken(37, -1);
                        if (stPercent != null) {
                            stPercent.tokencode = 296;
                        }
                    }
                    if (asourcetoken.tokencode == 298) {
                        final TSourceToken stPercent = asourcetoken.searchToken(61, -1);
                        if (stPercent != null) {
                            asourcetoken.tokencode = 264;
                        }
                    }
                    if (asourcetoken.tokencode != 304) {
                        break;
                    }
                    final TSourceToken stDo = asourcetoken.searchToken(501, -1);
                    if (stDo != null) {
                        asourcetoken.tokencode = 551;
                        break;
                    }
                    break;
                }
            }
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken != null) {
                yychar = asourcetoken.tokencode;
            } else {
                yychar = 0;
                if (waitingreturnforfloatdiv) {
                    lct.tokencode = 273;
                    if (lct.tokentype != ETokenType.ttslash) {
                        lct.tokentype = ETokenType.ttsqlpluscmd;
                    }
                }
            }
            if (yychar == 0 && prevst != null && prevst.tokencode == 345) {
                prevst.tokencode = 264;
            }
        }
    }

    void dosnowflakesqltexttotokenlist() {
        boolean insqlpluscmd = false;
        boolean isvalidplace = true;
        boolean waitingreturnforfloatdiv = false;
        boolean waitingreturnforsemicolon = false;
        boolean continuesqlplusatnewline = false;
        TSourceToken lct = null;
        TSourceToken prevst = null;
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        int yychar = asourcetoken.tokencode;
        while (yychar > 0) {
            this.sourcetokenlist.add(asourcetoken);
            switch (yychar) {
                case 257:
                case 258:
                case 259: {
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        break;
                    }
                    break;
                }
                case 260: {
                    if (insqlpluscmd) {
                        insqlpluscmd = false;
                        isvalidplace = true;
                        if (continuesqlplusatnewline) {
                            insqlpluscmd = true;
                            isvalidplace = false;
                            asourcetoken.insqlpluscmd = true;
                        }
                    }
                    if (waitingreturnforsemicolon) {
                        isvalidplace = true;
                    }
                    if (waitingreturnforfloatdiv) {
                        isvalidplace = true;
                        lct.tokencode = 273;
                        if (lct.tokentype != ETokenType.ttslash) {
                            lct.tokentype = ETokenType.ttsqlpluscmd;
                        }
                    }
                    this.flexer.insqlpluscmd = insqlpluscmd;
                    break;
                }
                default: {
                    continuesqlplusatnewline = false;
                    waitingreturnforsemicolon = false;
                    waitingreturnforfloatdiv = false;
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        if (asourcetoken.astext.equalsIgnoreCase("-")) {
                            continuesqlplusatnewline = true;
                        }
                    } else {
                        if (asourcetoken.tokentype == ETokenType.ttsemicolon) {
                            waitingreturnforsemicolon = true;
                        }
                        if (asourcetoken.tokentype == ETokenType.ttslash && (isvalidplace || this.IsValidPlaceForDivToSqlplusCmd(this.sourcetokenlist, asourcetoken.posinlist))) {
                            lct = asourcetoken;
                            waitingreturnforfloatdiv = true;
                        }
                        if (isvalidplace && this.isvalidsqlpluscmdInPostgresql(asourcetoken.astext)) {
                            asourcetoken.tokencode = 273;
                            if (asourcetoken.tokentype != ETokenType.ttslash) {
                                asourcetoken.tokentype = ETokenType.ttsqlpluscmd;
                            }
                            insqlpluscmd = true;
                            this.flexer.insqlpluscmd = insqlpluscmd;
                        }
                    }
                    isvalidplace = false;
                    if (prevst != null) {
                        if (prevst.tokencode == 345 && asourcetoken.tokencode != this.flexer.getkeywordvalue("JOIN")) {
                            prevst.tokencode = 264;
                        }
                        if (prevst.tokencode == 321 && asourcetoken.tokencode == this.flexer.getkeywordvalue("DEFERRABLE")) {
                            prevst.tokencode = this.flexer.getkeywordvalue("NOT_DEFERRABLE");
                        }
                    }
                    if (asourcetoken.tokencode == 345) {
                        prevst = asourcetoken;
                        break;
                    }
                    if (asourcetoken.tokencode == 321) {
                        prevst = asourcetoken;
                        break;
                    }
                    prevst = null;
                    break;
                }
            }
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken != null) {
                yychar = asourcetoken.tokencode;
            } else {
                yychar = 0;
                if (waitingreturnforfloatdiv) {
                    lct.tokencode = 273;
                    if (lct.tokentype != ETokenType.ttslash) {
                        lct.tokentype = ETokenType.ttsqlpluscmd;
                    }
                }
            }
            if (yychar == 0 && prevst != null && prevst.tokencode == 345) {
                prevst.tokencode = 264;
            }
        }
    }

    void doverticatexttotokenlist() {
        this.dopostgresqltexttotokenlist();
    }

    void docouchbasesqltexttotokenlist() {
        this.dopostgresqltexttotokenlist();
    }

    int splitQualifiedNameInBacktick(final TSourceToken asourcetoken) {
        int yychar = 0;
        final List<String> elephantList = Arrays.asList(TBaseType.getTextWithoutQuoted(asourcetoken.toString()).split("\\."));
        int p = 0;
        int offset = 0;
        for (final String s : elephantList) {
            final TSourceToken pst = new TSourceToken("`" + s + "`");
            pst.tokencode = asourcetoken.tokencode;
            pst.tokentype = asourcetoken.tokentype;
            pst.tokenstatus = asourcetoken.tokenstatus;
            pst.lineNo = asourcetoken.lineNo;
            pst.columnNo = asourcetoken.columnNo + offset;
            if (p == 0) {
                ++offset;
            }
            offset += s.length();
            pst.container = this.sourcetokenlist;
            if (p > 0) {
                ++this.sourcetokenlist.curpos;
            }
            pst.posinlist = this.sourcetokenlist.curpos;
            this.sourcetokenlist.add(pst);
            yychar = pst.tokencode;
            if (p != elephantList.size() - 1) {
                final TSourceToken periodst = new TSourceToken(".");
                periodst.tokencode = 46;
                periodst.tokentype = ETokenType.ttperiod;
                periodst.tokenstatus = asourcetoken.tokenstatus;
                periodst.lineNo = asourcetoken.lineNo;
                periodst.columnNo = asourcetoken.columnNo + offset;
                ++offset;
                periodst.container = this.sourcetokenlist;
                ++this.sourcetokenlist.curpos;
                periodst.posinlist = this.sourcetokenlist.curpos;
                this.sourcetokenlist.add(periodst);
                yychar = periodst.tokencode;
            }
            ++p;
        }
        return yychar;
    }

    void dobigquerysqltexttotokenlist() {
        this.flexer.tmpDelimiter = "";
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        int yychar = asourcetoken.tokencode;
        while (yychar > 0) {
            if (asourcetoken != null) {
                this.sourcetokenlist.add(asourcetoken);
            }
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken == null) {
                break;
            }
            yychar = asourcetoken.tokencode;
            if (asourcetoken.tokencode != 264 || !asourcetoken.toString().startsWith("`") || !asourcetoken.toString().endsWith("`") || asourcetoken.toString().indexOf(".") <= 0) {
                continue;
            }
            yychar = this.splitQualifiedNameInBacktick(asourcetoken);
            asourcetoken = null;
        }
    }

    void dosoqlsqltexttotokenlist() {
        this.domssqlsqltexttotokenlist();
    }

    void dogreenplumtexttotokenlist() {
        boolean insqlpluscmd = false;
        boolean isvalidplace = true;
        boolean waitingreturnforfloatdiv = false;
        boolean waitingreturnforsemicolon = false;
        boolean continuesqlplusatnewline = false;
        TSourceToken lct = null;
        TSourceToken prevst = null;
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        int yychar = asourcetoken.tokencode;
        while (yychar > 0) {
            this.sourcetokenlist.add(asourcetoken);
            switch (yychar) {
                case 257:
                case 258:
                case 259: {
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        break;
                    }
                    break;
                }
                case 260: {
                    if (insqlpluscmd) {
                        insqlpluscmd = false;
                        isvalidplace = true;
                        if (continuesqlplusatnewline) {
                            insqlpluscmd = true;
                            isvalidplace = false;
                            asourcetoken.insqlpluscmd = true;
                        }
                    }
                    if (waitingreturnforsemicolon) {
                        isvalidplace = true;
                    }
                    if (waitingreturnforfloatdiv) {
                        isvalidplace = true;
                        lct.tokencode = 273;
                        if (lct.tokentype != ETokenType.ttslash) {
                            lct.tokentype = ETokenType.ttsqlpluscmd;
                        }
                    }
                    this.flexer.insqlpluscmd = insqlpluscmd;
                    break;
                }
                default: {
                    continuesqlplusatnewline = false;
                    waitingreturnforsemicolon = false;
                    waitingreturnforfloatdiv = false;
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        if (asourcetoken.astext.equalsIgnoreCase("-")) {
                            continuesqlplusatnewline = true;
                        }
                    } else {
                        if (asourcetoken.tokentype == ETokenType.ttsemicolon) {
                            waitingreturnforsemicolon = true;
                        }
                        if (asourcetoken.tokentype == ETokenType.ttslash && (isvalidplace || this.IsValidPlaceForDivToSqlplusCmd(this.sourcetokenlist, asourcetoken.posinlist))) {
                            lct = asourcetoken;
                            waitingreturnforfloatdiv = true;
                        }
                        if (isvalidplace && this.isvalidsqlpluscmdInPostgresql(asourcetoken.astext)) {
                            asourcetoken.tokencode = 273;
                            if (asourcetoken.tokentype != ETokenType.ttslash) {
                                asourcetoken.tokentype = ETokenType.ttsqlpluscmd;
                            }
                            insqlpluscmd = true;
                            this.flexer.insqlpluscmd = insqlpluscmd;
                        }
                    }
                    isvalidplace = false;
                    if (prevst != null) {
                        if (prevst.tokencode == 345 && asourcetoken.tokencode != this.flexer.getkeywordvalue("JOIN")) {
                            prevst.tokencode = 264;
                        }
                        if (prevst.tokencode == 321 && asourcetoken.tokencode == this.flexer.getkeywordvalue("DEFERRABLE")) {
                            prevst.tokencode = this.flexer.getkeywordvalue("NOT_DEFERRABLE");
                        }
                    }
                    if (asourcetoken.tokencode == 345) {
                        prevst = asourcetoken;
                    } else if (asourcetoken.tokencode == 321) {
                        prevst = asourcetoken;
                    } else {
                        prevst = null;
                    }
                    if (asourcetoken.tokencode == this.flexer.getkeywordvalue("DIRECT_LOAD") || asourcetoken.tokencode == this.flexer.getkeywordvalue("ALL")) {
                        final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                        if (lcprevst != null && lcprevst.tokencode == 306) {
                            lcprevst.tokencode = 285;
                        }
                    }
                    if (asourcetoken.tokencode == 534) {
                        final TSourceToken stKeep = asourcetoken.searchToken(532, -2);
                        if (stKeep != null) {
                            stKeep.tokencode = 533;
                        }
                    }
                    if (asourcetoken.tokencode != 550) {
                        break;
                    }
                    final TSourceToken stPercent = asourcetoken.searchToken(37, -1);
                    if (stPercent != null) {
                        stPercent.tokencode = 296;
                        break;
                    }
                    break;
                }
            }
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken != null) {
                yychar = asourcetoken.tokencode;
            } else {
                yychar = 0;
                if (waitingreturnforfloatdiv) {
                    lct.tokencode = 273;
                    if (lct.tokentype != ETokenType.ttslash) {
                        lct.tokentype = ETokenType.ttsqlpluscmd;
                    }
                }
            }
            if (yychar == 0 && prevst != null && prevst.tokencode == 345) {
                prevst.tokencode = 264;
            }
        }
    }

    void donetezzatexttotokenlist() {
        boolean insqlpluscmd = false;
        boolean isvalidplace = true;
        boolean waitingreturnforfloatdiv = false;
        boolean waitingreturnforsemicolon = false;
        boolean continuesqlplusatnewline = false;
        TSourceToken lct = null;
        TSourceToken prevst = null;
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        int yychar = asourcetoken.tokencode;
        while (yychar > 0) {
            this.sourcetokenlist.add(asourcetoken);
            switch (yychar) {
                case 257:
                case 258:
                case 259: {
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        break;
                    }
                    break;
                }
                case 260: {
                    if (insqlpluscmd) {
                        insqlpluscmd = false;
                        isvalidplace = true;
                        if (continuesqlplusatnewline) {
                            insqlpluscmd = true;
                            isvalidplace = false;
                            asourcetoken.insqlpluscmd = true;
                        }
                    }
                    if (waitingreturnforsemicolon) {
                        isvalidplace = true;
                    }
                    if (waitingreturnforfloatdiv) {
                        isvalidplace = true;
                        lct.tokencode = 273;
                        if (lct.tokentype != ETokenType.ttslash) {
                            lct.tokentype = ETokenType.ttsqlpluscmd;
                        }
                    }
                    this.flexer.insqlpluscmd = insqlpluscmd;
                    break;
                }
                default: {
                    continuesqlplusatnewline = false;
                    waitingreturnforsemicolon = false;
                    waitingreturnforfloatdiv = false;
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        if (asourcetoken.astext.equalsIgnoreCase("-")) {
                            continuesqlplusatnewline = true;
                        }
                    } else {
                        if (asourcetoken.tokentype == ETokenType.ttsemicolon) {
                            waitingreturnforsemicolon = true;
                        }
                        if (asourcetoken.tokentype == ETokenType.ttslash && (isvalidplace || this.IsValidPlaceForDivToSqlplusCmd(this.sourcetokenlist, asourcetoken.posinlist))) {
                            lct = asourcetoken;
                            waitingreturnforfloatdiv = true;
                        }
                        if (isvalidplace && this.isvalidsqlpluscmdInPostgresql(asourcetoken.astext)) {
                            asourcetoken.tokencode = 273;
                            if (asourcetoken.tokentype != ETokenType.ttslash) {
                                asourcetoken.tokentype = ETokenType.ttsqlpluscmd;
                            }
                            insqlpluscmd = true;
                            this.flexer.insqlpluscmd = insqlpluscmd;
                        }
                    }
                    isvalidplace = false;
                    if (prevst != null) {
                        if (prevst.tokencode == 345 && asourcetoken.tokencode != this.flexer.getkeywordvalue("JOIN")) {
                            prevst.tokencode = 264;
                        }
                        if (prevst.tokencode == 321 && asourcetoken.tokencode == this.flexer.getkeywordvalue("DEFERRABLE")) {
                            prevst.tokencode = this.flexer.getkeywordvalue("NOT_DEFERRABLE");
                        }
                    }
                    if (asourcetoken.tokencode == 345) {
                        prevst = asourcetoken;
                    } else if (asourcetoken.tokencode == 321) {
                        prevst = asourcetoken;
                    } else {
                        prevst = null;
                    }
                    if (asourcetoken.tokencode == this.flexer.getkeywordvalue("DIRECT_LOAD") || asourcetoken.tokencode == this.flexer.getkeywordvalue("ALL")) {
                        final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                        if (lcprevst != null && lcprevst.tokencode == 306) {
                            lcprevst.tokencode = 285;
                        }
                    }
                    if (asourcetoken.tokencode != 534) {
                        break;
                    }
                    final TSourceToken stKeep = asourcetoken.searchToken(532, -2);
                    if (stKeep != null) {
                        stKeep.tokencode = 533;
                        break;
                    }
                    break;
                }
            }
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken != null) {
                yychar = asourcetoken.tokencode;
            } else {
                yychar = 0;
                if (waitingreturnforfloatdiv) {
                    lct.tokencode = 273;
                    if (lct.tokentype != ETokenType.ttslash) {
                        lct.tokentype = ETokenType.ttsqlpluscmd;
                    }
                }
            }
            if (yychar == 0 && prevst != null && prevst.tokencode == 345) {
                prevst.tokencode = 264;
            }
        }
    }

    private boolean spaceAtTheEndOfReturnToken(final String s) {
        final int pos = 0;
        return s != null && s.length() != 0 && (s.charAt(s.length() - 1) == ' ' || s.charAt(s.length() - 1) == '\t');
    }

    private int countLines(final String s) {
        int pos = 0;
        int lf = 0;
        int cr = 0;
        while (pos < s.length()) {
            if (s.charAt(pos) == '\r') {
                ++cr;
                ++pos;
            } else if (s.charAt(pos) == '\n') {
                ++lf;
                ++pos;
            } else {
                if (s.charAt(pos) != ' ') {
                    break;
                }
                ++pos;
            }
        }
        if (lf >= cr) {
            return lf;
        }
        return cr;
    }

    void dooraclesqltexttotokenlist() {
        boolean insqlpluscmd = false;
        boolean isvalidplace = true;
        boolean waitingreturnforfloatdiv = false;
        boolean waitingreturnforsemicolon = false;
        boolean continuesqlplusatnewline = false;
        ESqlPlusCmd currentCmdType = ESqlPlusCmd.spcUnknown;
        TSourceToken lct = null;
        TSourceToken prevst = null;
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        int yychar = asourcetoken.tokencode;
        while (yychar > 0) {
            this.sourcetokenlist.add(asourcetoken);
            switch (yychar) {
                case 257:
                case 258:
                case 259: {
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        break;
                    }
                    break;
                }
                case 260: {
                    if (insqlpluscmd) {
                        insqlpluscmd = false;
                        isvalidplace = true;
                        if (continuesqlplusatnewline) {
                            insqlpluscmd = true;
                            isvalidplace = false;
                            asourcetoken.insqlpluscmd = true;
                        }
                        if (!insqlpluscmd) {
                            currentCmdType = ESqlPlusCmd.spcUnknown;
                        }
                    }
                    if (waitingreturnforsemicolon) {
                        isvalidplace = true;
                    }
                    if (waitingreturnforfloatdiv) {
                        isvalidplace = true;
                        lct.tokencode = 273;
                        if (lct.tokentype != ETokenType.ttslash) {
                            lct.tokentype = ETokenType.ttsqlpluscmd;
                        }
                    }
                    if (this.countLines(asourcetoken.toString()) > 1) {
                        isvalidplace = true;
                    }
                    this.flexer.insqlpluscmd = insqlpluscmd;
                    break;
                }
                default: {
                    continuesqlplusatnewline = false;
                    waitingreturnforsemicolon = false;
                    waitingreturnforfloatdiv = false;
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        if (asourcetoken.astext.equalsIgnoreCase("-")) {
                            continuesqlplusatnewline = true;
                        }
                    } else {
                        if (asourcetoken.tokentype == ETokenType.ttsemicolon) {
                            waitingreturnforsemicolon = true;
                        }
                        if (asourcetoken.tokentype == ETokenType.ttslash && (isvalidplace || this.IsValidPlaceForDivToSqlplusCmd(this.sourcetokenlist, asourcetoken.posinlist))) {
                            lct = asourcetoken;
                            waitingreturnforfloatdiv = true;
                        }
                        currentCmdType = TSqlplusCmdStatement.searchCmd(asourcetoken.astext, asourcetoken.nextToken());
                        if (currentCmdType != ESqlPlusCmd.spcUnknown) {
                            if (isvalidplace) {
                                TSourceToken lnbreak = null;
                                boolean aRealSqlplusCmd = true;
                                if (this.sourcetokenlist.curpos > 0) {
                                    lnbreak = this.sourcetokenlist.get(this.sourcetokenlist.curpos - 1);
                                    aRealSqlplusCmd = !this.spaceAtTheEndOfReturnToken(lnbreak.toString());
                                }
                                if (aRealSqlplusCmd) {
                                    asourcetoken.prevTokenCode = asourcetoken.tokencode;
                                    asourcetoken.tokencode = 273;
                                    if (asourcetoken.tokentype != ETokenType.ttslash) {
                                        asourcetoken.tokentype = ETokenType.ttsqlpluscmd;
                                    }
                                    insqlpluscmd = true;
                                    this.flexer.insqlpluscmd = insqlpluscmd;
                                }
                            } else if (asourcetoken.tokencode == 481 && this.sourcetokenlist.returnbeforecurtoken(true)) {
                                asourcetoken.tokencode = 273;
                                if (asourcetoken.tokentype != ETokenType.ttslash) {
                                    asourcetoken.tokentype = ETokenType.ttsqlpluscmd;
                                }
                                insqlpluscmd = true;
                                this.flexer.insqlpluscmd = insqlpluscmd;
                            } else if (this.sourcetokenlist.returnbeforecurtoken(true)) {
                                final TSourceToken lnbreak = this.sourcetokenlist.get(this.sourcetokenlist.curpos - 1);
                                if (this.countLines(lnbreak.toString()) > 1 && !this.spaceAtTheEndOfReturnToken(lnbreak.toString())) {
                                    asourcetoken.tokencode = 273;
                                    if (asourcetoken.tokentype != ETokenType.ttslash) {
                                        asourcetoken.tokentype = ETokenType.ttsqlpluscmd;
                                    }
                                    insqlpluscmd = true;
                                    this.flexer.insqlpluscmd = insqlpluscmd;
                                }
                            }
                        }
                    }
                    isvalidplace = false;
                    if (prevst != null) {
                        if (prevst.tokencode == 345) {
                            if (asourcetoken.tokencode != this.flexer.getkeywordvalue("JOIN")) {
                                prevst.tokencode = 264;
                            }
                        } else if (prevst.tokencode == 321 && asourcetoken.tokencode == this.flexer.getkeywordvalue("DEFERRABLE")) {
                            prevst.tokencode = this.flexer.getkeywordvalue("NOT_DEFERRABLE");
                        }
                    }
                    if (asourcetoken.tokencode == 345) {
                        prevst = asourcetoken;
                    } else if (asourcetoken.tokencode == 321) {
                        prevst = asourcetoken;
                    } else {
                        prevst = null;
                    }
                    if (asourcetoken.tokencode == this.flexer.getkeywordvalue("DIRECT_LOAD") || asourcetoken.tokencode == this.flexer.getkeywordvalue("ALL")) {
                        final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                        if (lcprevst != null && lcprevst.tokencode == 306) {
                            lcprevst.tokencode = 285;
                            break;
                        }
                        break;
                    } else {
                        if (asourcetoken.tokencode == 534) {
                            final TSourceToken stKeep = asourcetoken.searchToken(532, -2);
                            if (stKeep != null) {
                                stKeep.tokencode = 533;
                            }
                            break;
                        }
                        if (asourcetoken.tokencode == 346) {
                            final TSourceToken stMatch = asourcetoken.searchToken(538, -1);
                            if (stMatch != null) {
                                asourcetoken.tokencode = 279;
                            }
                            break;
                        }
                        if (asourcetoken.tokencode == 324) {
                            final TSourceToken stFull = asourcetoken.searchToken(346, -1);
                            if (stFull != null) {
                                stFull.tokencode = 279;
                            } else {
                                final TSourceToken stNatural = asourcetoken.searchToken(539, -4);
                                if (stNatural != null) {
                                    stNatural.tokencode = 276;
                                }
                            }
                            break;
                        }
                        if (asourcetoken.tokencode == 347) {
                            final TSourceToken stFull = asourcetoken.searchToken(346, -1);
                            if (stFull != null) {
                                stFull.tokencode = 279;
                            }
                            break;
                        }
                        if (asourcetoken.tokencode == 525) {
                            final TSourceToken stType = asourcetoken.searchToken(541, -2);
                            if (stType != null) {
                                stType.tokencode = 540;
                            }
                            break;
                        }
                        if (asourcetoken.tokencode == 341) {
                            final TSourceToken stType = asourcetoken.searchToken(541, -2);
                            if (stType != null) {
                                stType.tokencode = 540;
                            }
                            break;
                        }
                        if (asourcetoken.tokencode == 543) {
                            final TSourceToken stType = asourcetoken.searchToken(541, -2);
                            if (stType != null) {
                                stType.tokencode = 540;
                            }
                            break;
                        }
                        if (asourcetoken.tokencode == 541) {
                            TSourceToken stPrev = asourcetoken.searchToken(314, -1);
                            if (stPrev != null) {
                                asourcetoken.tokencode = 540;
                            }
                            if (asourcetoken.tokencode == 541) {
                                stPrev = asourcetoken.searchToken(542, -1);
                                if (stPrev != null) {
                                    asourcetoken.tokencode = 540;
                                }
                            }
                            if (asourcetoken.tokencode == 541) {
                                stPrev = asourcetoken.searchToken(542, -1);
                                if (stPrev != null) {
                                    asourcetoken.tokencode = 540;
                                }
                            }
                            if (asourcetoken.tokencode == 541) {
                                stPrev = asourcetoken.searchToken(307, -1);
                                if (stPrev != null) {
                                    asourcetoken.tokencode = 540;
                                }
                            }
                            if (asourcetoken.tokencode == 541) {
                                stPrev = asourcetoken.searchToken(505, -1);
                                if (stPrev != null) {
                                    asourcetoken.tokencode = 540;
                                }
                            }
                            if (asourcetoken.tokencode == 541) {
                                stPrev = asourcetoken.searchToken(37, -1);
                                if (stPrev != null) {
                                    asourcetoken.tokencode = 540;
                                }
                            }
                            break;
                        }
                        if (asourcetoken.tokencode == 340 || asourcetoken.tokencode == 512) {
                            final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                            if (lcprevst != null && lcprevst.tokencode == 273 && lcprevst.toString().equalsIgnoreCase("connect")) {
                                lcprevst.tokencode = 481;
                                lcprevst.tokentype = ETokenType.ttkeyword;
                                this.flexer.insqlpluscmd = false;
                                continuesqlplusatnewline = false;
                                waitingreturnforsemicolon = false;
                                waitingreturnforfloatdiv = false;
                                isvalidplace = false;
                                insqlpluscmd = false;
                                break;
                            }
                            break;
                        } else if (asourcetoken.tokencode == 311) {
                            final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                            if (lcprevst != null && lcprevst.tokencode == 273 && lcprevst.toString().equalsIgnoreCase("start")) {
                                lcprevst.tokencode = 312;
                                lcprevst.tokentype = ETokenType.ttkeyword;
                                this.flexer.insqlpluscmd = false;
                                continuesqlplusatnewline = false;
                                waitingreturnforsemicolon = false;
                                waitingreturnforfloatdiv = false;
                                isvalidplace = false;
                                insqlpluscmd = false;
                                break;
                            }
                            break;
                        } else {
                            if (asourcetoken.tokencode != 325) {
                                break;
                            }
                            final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                            if (lcprevst == null || !lcprevst.astext.equalsIgnoreCase("a")) {
                                break;
                            }
                            final TSourceToken lcpp = this.getprevsolidtoken(lcprevst);
                            if (lcpp != null && (lcpp.tokencode == 321 || lcpp.tokencode == 525)) {
                                lcprevst.tokencode = 565;
                                asourcetoken.tokencode = 566;
                                break;
                            }
                            break;
                        }
                    }
                }
            }
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken != null) {
                yychar = asourcetoken.tokencode;
                if (asourcetoken.tokencode == 46 && this.getprevsolidtoken(asourcetoken) != null && (currentCmdType == ESqlPlusCmd.spcAppend || currentCmdType == ESqlPlusCmd.spcChange || currentCmdType == ESqlPlusCmd.spcInput || currentCmdType == ESqlPlusCmd.spcList || currentCmdType == ESqlPlusCmd.spcRun)) {
                    final TSourceToken lcprevst2 = this.getprevsolidtoken(asourcetoken);
                    lcprevst2.insqlpluscmd = false;
                    if (lcprevst2.prevTokenCode != 0) {
                        lcprevst2.tokencode = lcprevst2.prevTokenCode;
                    } else {
                        lcprevst2.tokencode = 264;
                    }
                    this.flexer.insqlpluscmd = false;
                    continuesqlplusatnewline = false;
                    waitingreturnforsemicolon = false;
                    waitingreturnforfloatdiv = false;
                    isvalidplace = false;
                    insqlpluscmd = false;
                }
            } else {
                yychar = 0;
                if (waitingreturnforfloatdiv) {
                    lct.tokencode = 273;
                    if (lct.tokentype != ETokenType.ttslash) {
                        lct.tokentype = ETokenType.ttsqlpluscmd;
                    }
                }
            }
            if (yychar == 0 && prevst != null && prevst.tokencode == 345) {
                prevst.tokencode = 264;
            }
        }
    }

    void dodb2sqltexttotokenlist() {
        boolean insqlpluscmd = false;
        boolean isvalidplace = true;
        int jdbc_escape_nest = 0;
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        for (int yychar = asourcetoken.tokencode; yychar > 0; yychar = asourcetoken.tokencode) {
            switch (yychar) {
                case 260: {
                    insqlpluscmd = false;
                    isvalidplace = true;
                    break;
                }
                case 258: {
                    if (asourcetoken.astext.toLowerCase().indexOf("scriptoptions") >= 0) {
                        asourcetoken.tokencode = 281;
                        asourcetoken.tokentype = ETokenType.ttidentifier;
                    }
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                        break;
                    }
                    break;
                }
                case 541: {
                    ++jdbc_escape_nest;
                    asourcetoken.tokencode = 259;
                    break;
                }
                case 542: {
                    --jdbc_escape_nest;
                    asourcetoken.tokencode = 259;
                    break;
                }
                default: {
                    if (asourcetoken.tokencode == 530 || asourcetoken.tokencode == 531 || asourcetoken.tokencode == 532 || asourcetoken.tokencode == 533) {
                        final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                        if (lcprevst != null && lcprevst.tokencode == 311) {
                            lcprevst.tokencode = 534;
                        }
                    }
                    if (insqlpluscmd) {
                        asourcetoken.insqlpluscmd = true;
                    } else if (isvalidplace && TBaseType.mycomparetext(asourcetoken.astext.toLowerCase(), "echo") == 0) {
                        asourcetoken.tokencode = 273;
                        if (asourcetoken.tokentype != ETokenType.ttslash) {
                            asourcetoken.tokentype = ETokenType.ttsqlpluscmd;
                        }
                        asourcetoken.insqlpluscmd = true;
                        insqlpluscmd = true;
                    }
                    isvalidplace = false;
                    break;
                }
            }
            this.sourcetokenlist.add(asourcetoken);
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken == null) {
                break;
            }
        }
    }

    void doteradatatexttotokenlist() {
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        for (int yychar = asourcetoken.tokencode; yychar > 0; yychar = asourcetoken.tokencode) {
            this.sourcetokenlist.add(asourcetoken);
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken == null) {
                break;
            }
            if (asourcetoken.tokencode == 552 || asourcetoken.tokencode == 553) {
                final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                if (lcprevst != null && lcprevst.tokencode == 321) {
                    lcprevst.tokencode = 285;
                }
            } else if (asourcetoken.tokencode == 59) {
                final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                if (lcprevst != null && lcprevst.tokencode == 59) {
                    asourcetoken.tokencode = 273;
                }
            } else if (asourcetoken.tokencode == 275) {
                if (asourcetoken.toString().toLowerCase().endsWith("begin")) {
                    asourcetoken.tokencode = 351;
                    asourcetoken.tokentype = ETokenType.ttkeyword;
                    final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                    if (lcprevst != null) {
                        lcprevst.tokencode = 276;
                    }
                }
            } else if (asourcetoken.tokencode == 281) {
                if (asourcetoken.toString().endsWith("008D")) {
                    asourcetoken.tokencode = 259;
                } else {
                    asourcetoken.tokencode = 264;
                }
            }
        }
    }

    void docommonsqltexttotokenlist() {
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        for (int yychar = asourcetoken.tokencode; yychar > 0; yychar = asourcetoken.tokencode) {
            this.sourcetokenlist.add(asourcetoken);
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken == null) {
                break;
            }
        }
    }

    void doodbcsqltexttotokenlist() {
        boolean insideODBC = false;
        TSourceToken odbcPrefix = null;
        this.domssqlsqltexttotokenlist();
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            final TSourceToken ast = this.sourcetokenlist.get(i);
            if (ast.tokencode == 123 || ast.tokencode == 277) {
                insideODBC = true;
                odbcPrefix = ast;
            }
            if (ast.tokencode == 125 || ast.tokencode == 278) {
                insideODBC = false;
                odbcPrefix = null;
            }
            if ((ast.tokencode == 531 || ast.tokencode == 532 || ast.tokencode == 533 || ast.tokencode == 535 || ast.tokencode == 534) && !insideODBC) {
                ast.tokencode = 264;
            }
            if (ast.tokencode == 468 && insideODBC) {
                odbcPrefix.setLinkToken(ast);
            }
        }
    }

    void dodaxsqltexttotokenlist() {
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        for (int yychar = asourcetoken.tokencode; yychar > 0; yychar = asourcetoken.tokencode) {
            this.sourcetokenlist.add(asourcetoken);
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken == null) {
                break;
            }
        }
    }

    void dohanasqltexttotokenlist() {
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        for (int yychar = asourcetoken.tokencode; yychar > 0; yychar = asourcetoken.tokencode) {
            this.sourcetokenlist.add(asourcetoken);
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken == null) {
                break;
            }
        }
    }

    void dohivetexttotokenlist() {
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        int yychar = asourcetoken.tokencode;
        while (yychar > 0) {
            if (asourcetoken != null) {
                this.sourcetokenlist.add(asourcetoken);
            }
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken == null) {
                break;
            }
            if (asourcetoken.tokencode == 534) {
                final TSourceToken token = asourcetoken.searchToken(41, -1);
                if (token != null) {
                    asourcetoken.tokencode = 264;
                }
            } else if (asourcetoken.tokencode == 40) {
            }
            yychar = asourcetoken.tokencode;
            if (asourcetoken.tokencode != 264 || !asourcetoken.toString().startsWith("`") || !asourcetoken.toString().endsWith("`") || asourcetoken.toString().indexOf(".") <= 0) {
                continue;
            }
            yychar = this.splitQualifiedNameInBacktick(asourcetoken);
            asourcetoken = null;
        }
    }

    void doimpalatexttotokenlist() {
        this.dohivetexttotokenlist();
    }

    void checkMySQLCommentToken(final TSourceToken cmtToken) {
    }

    void dosparksqltexttotokenlist() {
        boolean startDelimiter = false;
        this.flexer.tmpDelimiter = "";
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        for (int yychar = asourcetoken.tokencode; yychar > 0; yychar = asourcetoken.tokencode) {
            this.sourcetokenlist.add(asourcetoken);
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken == null) {
                break;
            }
            this.checkMySQLCommentToken(asourcetoken);
            if (asourcetoken.tokencode == 260 && startDelimiter) {
                startDelimiter = false;
                this.flexer.tmpDelimiter = this.sourcetokenlist.get(this.sourcetokenlist.size() - 1).astext;
            }
            if (asourcetoken.tokencode == 537) {
                final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                if (lcprevst != null && lcprevst.tokencode == 311) {
                    lcprevst.tokencode = 279;
                }
            }
        }
    }

    void doathenatexttotokenlist() {
        boolean startDelimiter = false;
        this.flexer.tmpDelimiter = "";
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        for (int yychar = asourcetoken.tokencode; yychar > 0; yychar = asourcetoken.tokencode) {
            this.sourcetokenlist.add(asourcetoken);
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken == null) {
                break;
            }
            this.checkMySQLCommentToken(asourcetoken);
            if (asourcetoken.tokencode == 260 && startDelimiter) {
                startDelimiter = false;
                this.flexer.tmpDelimiter = this.sourcetokenlist.get(this.sourcetokenlist.size() - 1).astext;
            }
        }
    }

    void dodatabrickstexttotokenlist() {
        boolean startDelimiter = false;
        this.flexer.tmpDelimiter = "";
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        for (int yychar = asourcetoken.tokencode; yychar > 0; yychar = asourcetoken.tokencode) {
            this.sourcetokenlist.add(asourcetoken);
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken == null) {
                break;
            }
            this.checkMySQLCommentToken(asourcetoken);
            if (asourcetoken.tokencode == 260 && startDelimiter) {
                startDelimiter = false;
                this.flexer.tmpDelimiter = this.sourcetokenlist.get(this.sourcetokenlist.size() - 1).astext;
            }
        }
    }

    void doprestotexttotokenlist() {
        boolean startDelimiter = false;
        this.flexer.tmpDelimiter = "";
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        for (int yychar = asourcetoken.tokencode; yychar > 0; yychar = asourcetoken.tokencode) {
            this.sourcetokenlist.add(asourcetoken);
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken == null) {
                break;
            }
            this.checkMySQLCommentToken(asourcetoken);
            if (asourcetoken.tokencode == 260 && startDelimiter) {
                startDelimiter = false;
                this.flexer.tmpDelimiter = this.sourcetokenlist.get(this.sourcetokenlist.size() - 1).astext;
            }
        }
    }

    void domysqltexttotokenlist() {
        boolean startDelimiter = false;
        this.flexer.tmpDelimiter = "";
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        int yychar = asourcetoken.tokencode;
        this.checkMySQLCommentToken(asourcetoken);
        if (asourcetoken.tokencode == 536) {
            startDelimiter = true;
        }
        while (yychar > 0) {
            this.sourcetokenlist.add(asourcetoken);
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken == null) {
                break;
            }
            this.checkMySQLCommentToken(asourcetoken);
            if (asourcetoken.tokencode == 260 && startDelimiter) {
                startDelimiter = false;
                this.flexer.tmpDelimiter = this.sourcetokenlist.get(this.sourcetokenlist.size() - 1).astext;
            }
            if (asourcetoken.tokencode == 536) {
                startDelimiter = true;
            }
            if (asourcetoken.tokencode == 537) {
                final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                if (lcprevst != null && lcprevst.tokencode == 311) {
                    lcprevst.tokencode = 279;
                }
            }
            if (asourcetoken.tokencode == 548 || asourcetoken.tokencode == 549 || asourcetoken.tokencode == 550) {
                final TSourceToken lcprevst = this.getprevsolidtoken(asourcetoken);
                if (lcprevst != null && lcprevst.tokencode != 123) {
                    asourcetoken.tokencode = 264;
                }
            }
            yychar = asourcetoken.tokencode;
        }
    }

    void doMdxtexttotokenlist() {
        TSourceToken asourcetoken = this.getanewsourcetoken();
        if (asourcetoken == null) {
            return;
        }
        for (int yychar = asourcetoken.tokencode; yychar > 0; yychar = asourcetoken.tokencode) {
            this.sourcetokenlist.add(asourcetoken);
            asourcetoken = this.getanewsourcetoken();
            if (asourcetoken == null) {
                break;
            }
        }
    }

    void dosqltexttotokenlist() {
        switch (this.dbVendor) {
            case dbvmssql:
            case dbvazuresql: {
                this.domssqlsqltexttotokenlist();
                break;
            }
            case dbvinformix: {
                this.doinformixtexttotokenlist();
                break;
            }
            case dbvsybase: {
                this.dosybasesqltexttotokenlist();
                break;
            }
            case dbvoracle: {
                this.dooraclesqltexttotokenlist();
                break;
            }
            case dbvdb2: {
                this.dodb2sqltexttotokenlist();
                break;
            }
            case dbvteradata: {
                this.doteradatatexttotokenlist();
                break;
            }
            case dbvpostgresql: {
                this.dopostgresqltexttotokenlist();
                break;
            }
            case dbvredshift: {
                this.doredshifttexttotokenlist();
                break;
            }
            case dbvgreenplum: {
                this.dogreenplumtexttotokenlist();
                break;
            }
            case dbvmdx: {
                this.doMdxtexttotokenlist();
                break;
            }
            case dbvnetezza: {
                this.donetezzatexttotokenlist();
                break;
            }
            case dbvhive: {
                this.dohivetexttotokenlist();
                break;
            }
            case dbvimpala: {
                this.doimpalatexttotokenlist();
                break;
            }
            case dbvmysql: {
                this.domysqltexttotokenlist();
                break;
            }
            case dbvhana: {
                this.dohanasqltexttotokenlist();
                break;
            }
            case dbvdax: {
                this.dodaxsqltexttotokenlist();
                break;
            }
            case dbvodbc: {
                this.doodbcsqltexttotokenlist();
                break;
            }
            case dbvvertica: {
                this.doverticatexttotokenlist();
                break;
            }
            case dbvopenedge: {
                this.domssqlsqltexttotokenlist();
                break;
            }
            case dbvcouchbase: {
                this.docouchbasesqltexttotokenlist();
                break;
            }
            case dbvsnowflake: {
                this.dosnowflakesqltexttotokenlist();
                break;
            }
            case dbvbigquery: {
                this.dobigquerysqltexttotokenlist();
                break;
            }
            case dbvsoql: {
                this.dosoqlsqltexttotokenlist();
                break;
            }
            case dbvsparksql: {
                this.dosparksqltexttotokenlist();
                break;
            }
            case dbvpresto: {
                this.doprestotexttotokenlist();
                break;
            }
            case dbvathena: {
                this.doathenatexttotokenlist();
                break;
            }
            case dbvdatabricks: {
                this.dodatabrickstexttotokenlist();
                break;
            }
            case dbvgaussdb: {
                this.dogaussdbtexttotokenlist();
                break;
            }
            case dbvansi: {
                this.doansitexttotokenlist();
                break;
            }
            default: {
                this.docommonsqltexttotokenlist();
                break;
            }
        }
        if (this.sourcetokenlist.size() > 0) {
            TSourceToken lcPrevToken = null;
            for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
                this.sourcetokenlist.get(i).setPrevTokenInChain(lcPrevToken);
                if (i != this.sourcetokenlist.size() - 1) {
                    this.sourcetokenlist.get(i).setNextTokenInChain(this.sourcetokenlist.get(i + 1));
                }
                lcPrevToken = this.sourcetokenlist.get(i);
            }
        }
        this.closeFileStream();
    }

    void doongetrawsqlstatementevent(final TCustomSqlStatement pcsqlstatement) {
        pcsqlstatement.setGsqlparser(this);
        pcsqlstatement.parser = this.fparser;
        pcsqlstatement.plsqlparser = this.fplsqlparser;
        pcsqlstatement.setStartToken(pcsqlstatement.sourcetokenlist.get(0));
        pcsqlstatement.setEndToken(pcsqlstatement.sourcetokenlist.get(pcsqlstatement.sourcetokenlist.size() - 1));
        this.sqlstatements.add(pcsqlstatement);
        if (this.dbVendor == EDbVendor.dbvgaussdb && (pcsqlstatement.sqlstatementtype == ESqlStatementType.sstcreateprocedure || pcsqlstatement.sqlstatementtype == ESqlStatementType.sstcreatefunction)) {
            if (this.isOracleStyleRoutine) {
                if (this.stFunction != null) {
                    this.stFunction.tokencode = 631;
                } else if (this.stProcedure != null) {
                    this.stProcedure.tokencode = 630;
                }
            }
            this.stFunction = null;
            this.stProcedure = null;
            this.isOracleStyleRoutine = true;
        }
        if ((this.dbVendor == EDbVendor.dbvpostgresql || this.dbVendor == EDbVendor.dbvgreenplum) && pcsqlstatement instanceof TRoutine && !((TRoutine) pcsqlstatement).isBodyInSQL()) {
            boolean inBody = false;
            for (int i = 0; i < pcsqlstatement.sourcetokenlist.size(); ++i) {
                final TSourceToken st = pcsqlstatement.sourcetokenlist.get(i);
                if (st.tokencode == 623 || st.tokencode == 559) {
                    if (inBody) {
                        inBody = false;
                        break;
                    }
                    inBody = true;
                } else if (inBody) {
                    st.tokencode = 273;
                }
            }
        }
    }

    int doredshiftgetrawsqlstatements() {
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode == 535) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null) {
                    if (st1.tokencode != 40) {
                        ast.tokencode = 264;
                    }
                }
            } else if (ast.tokencode == 537) {
                final TSourceToken st1 = ast.searchToken(60, 1);
                if (st1 != null) {
                    ast.tokencode = 538;
                }
            }
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (this.gcurrentsqlstatement != null) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                        }
                        if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                            ast.tokentype = ETokenType.ttsimplecomment;
                            ast.tokencode = 258;
                            break;
                        }
                        break;
                    } else {
                        if (ast.tokencode == 273) {
                            gst = EFindSqlStateType.stsqlplus;
                            (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                            break;
                        }
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (this.gcurrentsqlstatement != null) {
                            gst = EFindSqlStateType.stsql;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                        ast.tokentype = ETokenType.tttokenlizererrortoken;
                        gst = EFindSqlStateType.sterror;
                        this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                        this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                }
                case stsqlplus: {
                    if (ast.insqlpluscmd) {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                    gst = EFindSqlStateType.stnormal;
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    break;
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (this.sourcetokenlist.sqlplusaftercurtoken()) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
            }
        }
        if (this.gcurrentsqlstatement != null && (gst == EFindSqlStateType.stsqlplus || gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return this.syntaxErrors.size();
    }

    int doverticagetrawsqlstatements() {
        int waitingEnd = 0;
        boolean foundEnd = false;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode == 394) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null && st1.tokencode == 40) {
                    ast.tokencode = 532;
                }
            } else if (ast.tokencode == 533 || ast.tokencode == 534) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null && st1.tokencode != 40) {
                    ast.tokencode = 264;
                }
            }
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (this.gcurrentsqlstatement != null) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                        }
                        if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                            ast.tokentype = ETokenType.ttsimplecomment;
                            ast.tokencode = 258;
                            break;
                        }
                        break;
                    } else {
                        if (ast.tokencode == 273) {
                            gst = EFindSqlStateType.stsqlplus;
                            (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                            break;
                        }
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (this.gcurrentsqlstatement == null) {
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        if (!this.gcurrentsqlstatement.isverticaplsql()) {
                            gst = EFindSqlStateType.stsql;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        gst = EFindSqlStateType.ststoredprocedure;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        foundEnd = true;
                        if (ast.tokencode == 351 || ast.tokencode == 479 || ast.searchToken(479, 4) != null) {
                            waitingEnd = 1;
                            break;
                        }
                        break;
                    }
                }
                case stsqlplus: {
                    if (ast.insqlpluscmd) {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                    gst = EFindSqlStateType.stnormal;
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    break;
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (this.sourcetokenlist.sqlplusaftercurtoken()) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case ststoredprocedure: {
                    if (ast.tokencode == 351) {
                        ++waitingEnd;
                        foundEnd = false;
                    } else if (ast.tokencode == 305) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 316) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 490) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 313) {
                        foundEnd = true;
                        if (--waitingEnd < 0) {
                            waitingEnd = 0;
                        }
                    }
                    if (ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    } else if (ast.tokentype == ETokenType.ttperiod && this.sourcetokenlist.returnaftercurtoken(false) && this.sourcetokenlist.returnbeforecurtoken(false)) {
                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    } else {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokentype == ETokenType.ttsemicolon && waitingEnd == 0 && foundEnd && this.gcurrentsqlstatement.VerticaStatementCanBeSeparatedByBeginEndPair()) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        }
                    }
                    if (ast.tokencode != 273) {
                        break;
                    }
                    final int m = this.flexer.getkeywordvalue(ast.astext);
                    if (m != 0) {
                        ast.tokencode = m;
                        break;
                    }
                    ast.tokencode = 264;
                    break;
                }
            }
        }
        if (this.gcurrentsqlstatement != null && (gst == EFindSqlStateType.stsqlplus || gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return this.syntaxErrors.size();
    }

    boolean checkTokenPairWithEnd(final int tokencode) {
        return tokencode == 305 || tokencode == 316 || tokencode == 490 || tokencode == 494 || tokencode == 460 || tokencode == 306 || tokencode == 316;
    }

    int dobigquerygetrawsqlstatements() {
        final int errorcount = 0;
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        final int beginNested = 0;
        int waitingEnd = 0;
        TSourceToken ast = null;
        TSourceToken lcprevsolidtoken = null;
        final boolean waitingDelimiter = false;
        final int[] waitingEnds = new int[1024];
        final stored_procedure_type[] sptype = new stored_procedure_type[1024];
        final stored_procedure_status[] procedure_status = new stored_procedure_status[1024];
        boolean endBySlashOnly = true;
        int nestedProcedures = 0;
        final int nestedParenthesis = 0;
        this.userDelimiterStr = this.defaultDelimiterStr;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode == 529) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null && st1.tokencode == 40) {
                    ast.tokencode = 530;
                }
            } else if (ast.tokencode == 262) {
                if (TTypeName.searchTypeByName(lcprevsolidtoken.toString()) != null && lcprevsolidtoken.tokencode != 416) {
                    lcprevsolidtoken.tokencode = 531;
                }
            } else if (ast.tokencode == 393 || ast.tokencode == 394) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null) {
                    if (st1.tokencode != 262) {
                        if (st1.tokencode == 40) {
                            ast.tokencode = 264;
                        }
                    }
                }
            } else if (ast.tokencode == 329) {
                final TSourceToken st1 = ast.prevSolidToken();
                if (st1 != null && st1.tokencode == 46) {
                    ast.tokencode = 264;
                }
            }
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        break;
                    } else {
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                            if (this.gcurrentsqlstatement.isBigQueryplsql()) {
                                nestedProcedures = 0;
                                gst = EFindSqlStateType.ststoredprocedure;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                    case sstplsql_createprocedure:
                                    case sstcreateprocedure: {
                                        sptype[nestedProcedures] = stored_procedure_type.procedure;
                                        break;
                                    }
                                    case sstplsql_createfunction: {
                                        sptype[nestedProcedures] = stored_procedure_type.function;
                                        break;
                                    }
                                    case sstplsql_createpackage: {
                                        sptype[nestedProcedures] = stored_procedure_type.package_spec;
                                        if (ast.searchToken(526, 5) != null) {
                                            sptype[nestedProcedures] = stored_procedure_type.package_body;
                                            break;
                                        }
                                        break;
                                    }
                                    case sst_plsql_block: {
                                        sptype[nestedProcedures] = stored_procedure_type.block_with_declare;
                                        if (ast.tokencode == 351) {
                                            sptype[nestedProcedures] = stored_procedure_type.block_with_begin;
                                            break;
                                        }
                                        break;
                                    }
                                    case sstplsql_createtrigger: {
                                        sptype[nestedProcedures] = stored_procedure_type.create_trigger;
                                        break;
                                    }
                                    case sstoraclecreatelibrary: {
                                        sptype[nestedProcedures] = stored_procedure_type.create_library;
                                        break;
                                    }
                                    case sstplsql_createtype_placeholder: {
                                        gst = EFindSqlStateType.stsql;
                                        break;
                                    }
                                    default: {
                                        sptype[nestedProcedures] = stored_procedure_type.others;
                                        break;
                                    }
                                }
                                if (sptype[0] == stored_procedure_type.block_with_declare) {
                                    endBySlashOnly = false;
                                    procedure_status[0] = stored_procedure_status.is_as;
                                } else if (sptype[0] == stored_procedure_type.block_with_begin) {
                                    endBySlashOnly = false;
                                    procedure_status[0] = stored_procedure_status.body;
                                } else if (sptype[0] == stored_procedure_type.procedure) {
                                    endBySlashOnly = false;
                                    procedure_status[0] = stored_procedure_status.start;
                                } else if (sptype[0] == stored_procedure_type.function) {
                                    endBySlashOnly = false;
                                    procedure_status[0] = stored_procedure_status.start;
                                } else if (sptype[0] == stored_procedure_type.package_spec) {
                                    endBySlashOnly = false;
                                    procedure_status[0] = stored_procedure_status.start;
                                } else if (sptype[0] == stored_procedure_type.package_body) {
                                    endBySlashOnly = false;
                                    procedure_status[0] = stored_procedure_status.start;
                                } else if (sptype[0] == stored_procedure_type.create_trigger) {
                                    endBySlashOnly = false;
                                    procedure_status[0] = stored_procedure_status.start;
                                } else if (sptype[0] == stored_procedure_type.create_library) {
                                    endBySlashOnly = false;
                                    procedure_status[0] = stored_procedure_status.bodyend;
                                } else {
                                    endBySlashOnly = true;
                                    procedure_status[0] = stored_procedure_status.bodyend;
                                }
                                if (ast.tokencode == 351 || ast.tokencode == 479 || ast.searchToken(479, 4) != null) {
                                    waitingEnds[nestedProcedures] = 1;
                                }
                            } else if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sst_ifstmt || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sst_loopstmt || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstRepeat || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstWhilestmt || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstForStmt || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sst_plsql_block || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sst_casestmt) {
                                gst = EFindSqlStateType.stBigQueryIf;
                                waitingEnd = 1;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                            } else {
                                gst = EFindSqlStateType.stsql;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                            }
                        }
                        if (!TBaseType.assigned(this.gcurrentsqlstatement)) {
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        break;
                    }
                }
                case stBigQueryIf: {
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    if (this.checkTokenPairWithEnd(ast.tokencode)) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                            break;
                        }
                        break;
                    } else {
                        if (ast.tokencode == 313) {
                            final TSourceToken next = ast.nextSolidToken();
                            if (next != null) {
                                if (this.checkTokenPairWithEnd(next.tokencode)) {
                                    --waitingEnd;
                                } else if (next.tokencode == 59) {
                                    --waitingEnd;
                                }
                            }
                            break;
                        }
                        if (ast.tokencode == 59 && waitingEnd == 0) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        break;
                    }
                }
                case stsqlplus: {
                    if (ast.tokencode == 260) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon && this.gcurrentsqlstatement.sqlstatementtype != ESqlStatementType.sstmysqldelimiter) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (ast.toString().equalsIgnoreCase(this.userDelimiterStr)) {
                        gst = EFindSqlStateType.stnormal;
                        ast.tokencode = 59;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    if (ast.tokencode == 260 && this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmysqldelimiter) {
                        gst = EFindSqlStateType.stnormal;
                        this.userDelimiterStr = "";
                        for (int k = 0; k < this.gcurrentsqlstatement.sourcetokenlist.size(); ++k) {
                            final TSourceToken st2 = this.gcurrentsqlstatement.sourcetokenlist.get(k);
                            if (st2.tokencode != 536 && st2.tokencode != 260) {
                                if (st2.tokencode != 259) {
                                    this.userDelimiterStr += st2.toString();
                                }
                            }
                        }
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    break;
                }
                case ststoredprocedure: {
                    if (procedure_status[nestedProcedures] != stored_procedure_status.bodyend) {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                    }
                    switch (procedure_status[nestedProcedures]) {
                        case start: {
                            if (ast.tokencode == 341 || ast.tokencode == 525) {
                                if (sptype[nestedProcedures] == stored_procedure_type.create_trigger) {
                                    break;
                                }
                                if (sptype[0] == stored_procedure_type.package_spec && nestedProcedures > 0) {
                                    break;
                                }
                                procedure_status[nestedProcedures] = stored_procedure_status.is_as;
                                if (ast.searchToken("language", 1) == null) {
                                    break;
                                }
                                if (nestedProcedures == 0) {
                                    gst = EFindSqlStateType.stsql;
                                    break;
                                }
                                procedure_status[nestedProcedures] = stored_procedure_status.body;
                                --nestedProcedures;
                                break;
                            } else {
                                if (ast.tokencode == 351) {
                                    if (sptype[nestedProcedures] == stored_procedure_type.create_trigger) {
                                        final int[] array = waitingEnds;
                                        final int n = nestedProcedures;
                                        ++array[n];
                                    }
                                    if (nestedProcedures > 0) {
                                        --nestedProcedures;
                                    }
                                    procedure_status[nestedProcedures] = stored_procedure_status.body;
                                    waitingEnds[nestedProcedures] = 1;
                                    break;
                                }
                                if (ast.tokencode == 313) {
                                    if (nestedProcedures > 0 && waitingEnds[nestedProcedures - 1] == 1 && (sptype[nestedProcedures - 1] == stored_procedure_type.package_body || sptype[nestedProcedures - 1] == stored_procedure_type.package_spec)) {
                                        --nestedProcedures;
                                        procedure_status[nestedProcedures] = stored_procedure_status.bodyend;
                                        break;
                                    }
                                    break;
                                } else if (ast.tokencode == 477 || ast.tokencode == 478) {
                                    if (nestedProcedures > 0 && waitingEnds[nestedProcedures] == 0 && procedure_status[nestedProcedures - 1] == stored_procedure_status.is_as) {
                                        --nestedProcedures;
                                        ++nestedProcedures;
                                        waitingEnds[nestedProcedures] = 0;
                                        procedure_status[nestedProcedures] = stored_procedure_status.start;
                                        break;
                                    }
                                    break;
                                } else {
                                    if (sptype[nestedProcedures] == stored_procedure_type.create_trigger && ast.tokencode == 315) {
                                        procedure_status[nestedProcedures] = stored_procedure_status.is_as;
                                        break;
                                    }
                                    if (sptype[nestedProcedures] == stored_procedure_type.create_trigger && ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                                        gst = EFindSqlStateType.stnormal;
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        break;
                                    }
                                    if (sptype[nestedProcedures] == stored_procedure_type.create_trigger) {
                                        if (ast.tokencode == 545) {
                                            final TSourceToken compoundSt = ast.searchToken(560, -1);
                                            if (compoundSt != null) {
                                                procedure_status[nestedProcedures] = stored_procedure_status.body;
                                                final int[] array2 = waitingEnds;
                                                final int n2 = nestedProcedures;
                                                ++array2[n2];
                                            }
                                            break;
                                        }
                                        break;
                                    } else {
                                        if (sptype[nestedProcedures] != stored_procedure_type.function || ast.tokencode != 528 || (ast.searchToken("aggregate", -1) == null && ast.searchToken("pipelined", -1) == null)) {
                                            break;
                                        }
                                        if (nestedProcedures == 0) {
                                            gst = EFindSqlStateType.stsql;
                                            break;
                                        }
                                        procedure_status[nestedProcedures] = stored_procedure_status.body;
                                        --nestedProcedures;
                                        break;
                                    }
                                }
                            }
                        }
                        case is_as: {
                            if (ast.tokencode == 477 || ast.tokencode == 478) {
                                ++nestedProcedures;
                                waitingEnds[nestedProcedures] = 0;
                                procedure_status[nestedProcedures] = stored_procedure_status.start;
                                if (nestedProcedures > 1023) {
                                    gst = EFindSqlStateType.sterror;
                                    --nestedProcedures;
                                    break;
                                }
                                break;
                            } else {
                                if (ast.tokencode == 351) {
                                    Label_2365:
                                    {
                                        if (nestedProcedures == 0) {
                                            if (sptype[nestedProcedures] == stored_procedure_type.package_body) {
                                                break Label_2365;
                                            }
                                            if (sptype[nestedProcedures] == stored_procedure_type.package_spec) {
                                                break Label_2365;
                                            }
                                        }
                                        final int[] array3 = waitingEnds;
                                        final int n3 = nestedProcedures;
                                        ++array3[n3];
                                    }
                                    procedure_status[nestedProcedures] = stored_procedure_status.body;
                                    break;
                                }
                                if (ast.tokencode == 313) {
                                    if (nestedProcedures == 0 && waitingEnds[nestedProcedures] == 1 && (sptype[nestedProcedures] == stored_procedure_type.package_body || sptype[nestedProcedures] == stored_procedure_type.package_spec)) {
                                        procedure_status[nestedProcedures] = stored_procedure_status.bodyend;
                                        final int[] array4 = waitingEnds;
                                        final int n4 = nestedProcedures;
                                        --array4[n4];
                                        break;
                                    }
                                    final int[] array5 = waitingEnds;
                                    final int n5 = nestedProcedures;
                                    --array5[n5];
                                    break;
                                } else {
                                    if (ast.tokencode == 316 && ast.searchToken(59, 1) == null) {
                                        final int[] array6 = waitingEnds;
                                        final int n6 = nestedProcedures;
                                        ++array6[n6];
                                        break;
                                    }
                                    break;
                                }
                            }
                        }
                        case body: {
                            if (ast.tokencode == 351) {
                                final int[] array7 = waitingEnds;
                                final int n7 = nestedProcedures;
                                ++array7[n7];
                                break;
                            }
                            if (ast.tokencode == 305) {
                                if (ast.searchToken(59, 2) == null) {
                                    final int[] array8 = waitingEnds;
                                    final int n8 = nestedProcedures;
                                    ++array8[n8];
                                    break;
                                }
                                break;
                            } else if (ast.tokencode == 316) {
                                if (ast.searchToken(59, 2) == null && ast.searchToken(313, -1) == null) {
                                    final int[] array9 = waitingEnds;
                                    final int n9 = nestedProcedures;
                                    ++array9[n9];
                                    break;
                                }
                                break;
                            } else if (ast.tokencode == 490 || ast.tokencode == 460 || ast.tokencode == 494 || ast.tokencode == 306) {
                                if (ast.searchToken(313, -1) == null || ast.searchToken(59, 2) == null) {
                                    final int[] array10 = waitingEnds;
                                    final int n10 = nestedProcedures;
                                    ++array10[n10];
                                    break;
                                }
                                break;
                            } else if (ast.tokencode == 313) {
                                final int[] array11 = waitingEnds;
                                final int n11 = nestedProcedures;
                                --array11[n11];
                                if (waitingEnds[nestedProcedures] != 0) {
                                    break;
                                }
                                if (nestedProcedures == 0) {
                                    procedure_status[nestedProcedures] = stored_procedure_status.bodyend;
                                    break;
                                }
                                --nestedProcedures;
                                procedure_status[nestedProcedures] = stored_procedure_status.is_as;
                                break;
                            } else {
                                if (waitingEnds[nestedProcedures] == 0 && ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                                    ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                                    gst = EFindSqlStateType.stnormal;
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    break;
                                }
                                break;
                            }
                        }
                        case bodyend: {
                            if (ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                                ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.tokencode == 59) {
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(479, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(477, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(478, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(307, 1) != null && ast.searchToken(479, 4) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(307, 1) != null && ast.searchToken(546, 4) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(426, 1) != null && ast.searchToken(545, 2) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(301, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(419, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(423, 1) != null && ast.searchToken(440, 2) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                    }
                    if (ast.tokencode == 273) {
                        final int m = this.flexer.getkeywordvalue(ast.astext);
                        if (m != 0) {
                            ast.tokencode = m;
                        } else if (ast.tokentype == ETokenType.ttslash) {
                            ast.tokencode = 47;
                        } else {
                            ast.tokencode = 264;
                        }
                    }
                    final int wrapped_keyword_max_pos = 20;
                    if (ast.tokencode != 535 || ast.posinlist - this.gcurrentsqlstatement.sourcetokenlist.get(0).posinlist >= 20) {
                        break;
                    }
                    if (this.gcurrentsqlstatement instanceof TCommonStoredProcedureSqlStatement) {
                        ((TCommonStoredProcedureSqlStatement) this.gcurrentsqlstatement).setWrapped(true);
                    }
                    if (this.gcurrentsqlstatement instanceof TPlsqlCreatePackage && ast.prevSolidToken() != null) {
                        ((TPlsqlCreatePackage) this.gcurrentsqlstatement).setPackageName(this.fparser.getNf().createObjectNameWithPart(ast.prevSolidToken()));
                        break;
                    }
                    break;
                }
            }
        }
        if (TBaseType.assigned(this.gcurrentsqlstatement) && (gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.stBigQueryIf || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return errorcount;
    }

    int docouchbasegetrawsqlstatements() {
        int waitingEnd = 0;
        boolean foundEnd = false;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (this.gcurrentsqlstatement != null) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                        }
                        if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                            ast.tokentype = ETokenType.ttsimplecomment;
                            ast.tokencode = 258;
                            break;
                        }
                        break;
                    } else {
                        if (ast.tokencode == 273) {
                            gst = EFindSqlStateType.stsqlplus;
                            (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                            break;
                        }
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (this.gcurrentsqlstatement != null) {
                            gst = EFindSqlStateType.stsql;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                        ast.tokentype = ETokenType.tttokenlizererrortoken;
                        gst = EFindSqlStateType.sterror;
                        this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                        this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                }
                case stsqlplus: {
                    if (ast.insqlpluscmd) {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                    gst = EFindSqlStateType.stnormal;
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    break;
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (this.sourcetokenlist.sqlplusaftercurtoken()) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case ststoredprocedure: {
                    if (ast.tokencode == 351) {
                        ++waitingEnd;
                        foundEnd = false;
                    } else if (ast.tokencode == 305) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 316) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 490) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 313) {
                        foundEnd = true;
                        if (--waitingEnd < 0) {
                            waitingEnd = 0;
                        }
                    }
                    if (ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    } else if (ast.tokentype == ETokenType.ttperiod && this.sourcetokenlist.returnaftercurtoken(false) && this.sourcetokenlist.returnbeforecurtoken(false)) {
                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    } else {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokentype == ETokenType.ttsemicolon && waitingEnd == 0 && foundEnd && this.gcurrentsqlstatement.VerticaStatementCanBeSeparatedByBeginEndPair()) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        }
                    }
                    if (ast.tokencode != 273) {
                        break;
                    }
                    final int m = this.flexer.getkeywordvalue(ast.astext);
                    if (m != 0) {
                        ast.tokencode = m;
                        break;
                    }
                    ast.tokencode = 264;
                    break;
                }
            }
        }
        if (this.gcurrentsqlstatement != null && (gst == EFindSqlStateType.stsqlplus || gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return this.syntaxErrors.size();
    }

    int doathenagetrawsqlstatements() {
        int waitingEnd = 0;
        boolean foundEnd = false;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (this.gcurrentsqlstatement != null) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                        }
                        if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                            ast.tokentype = ETokenType.ttsimplecomment;
                            ast.tokencode = 258;
                            break;
                        }
                        break;
                    } else {
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (this.gcurrentsqlstatement == null) {
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        if (!this.gcurrentsqlstatement.isathenaplsql()) {
                            gst = EFindSqlStateType.stsql;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        gst = EFindSqlStateType.ststoredprocedure;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        foundEnd = false;
                        if (ast.tokencode == 351 || ast.tokencode == 479 || ast.searchToken(479, 4) != null) {
                            waitingEnd = 1;
                            break;
                        }
                        break;
                    }
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (this.sourcetokenlist.sqlplusaftercurtoken()) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case ststoredprocedure: {
                    if (ast.tokencode == 351) {
                        ++waitingEnd;
                    } else if (ast.tokencode == 305) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 316) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 490) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 313) {
                        foundEnd = true;
                        if (--waitingEnd < 0) {
                            waitingEnd = 0;
                        }
                    }
                    if (ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    } else if (ast.tokentype == ETokenType.ttperiod && this.sourcetokenlist.returnaftercurtoken(false) && this.sourcetokenlist.returnbeforecurtoken(false)) {
                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    } else {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokentype == ETokenType.ttsemicolon && waitingEnd == 0 && foundEnd) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        }
                    }
                    if (ast.tokencode != 273) {
                        break;
                    }
                    final int m = this.flexer.getkeywordvalue(ast.astext);
                    if (m != 0) {
                        ast.tokencode = m;
                        break;
                    }
                    ast.tokencode = 264;
                    break;
                }
            }
        }
        if (this.gcurrentsqlstatement != null && (gst == EFindSqlStateType.stsqlplus || gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return this.syntaxErrors.size();
    }

    int dodatabricksgetrawsqlstatements() {
        int waitingEnd = 0;
        boolean foundEnd = false;
        final EDataType tmpDatatype = null;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode == 326) {
                final TSourceToken stParen = ast.searchToken(40, 1);
                if (stParen != null) {
                    final TSourceToken stInsert = ast.searchToken(302, -ast.posinlist);
                    if (stInsert != null) {
                        final TSourceToken stSemiColon = ast.searchToken(59, -ast.posinlist);
                        if (stSemiColon == null || stSemiColon.posinlist <= stInsert.posinlist) {
                            final TSourceToken stFrom = ast.searchToken(329, -ast.posinlist);
                            if (stFrom == null) {
                                ast.tokencode = 535;
                            }
                        }
                    }
                }
            } else if ((ast.tokencode == 262 || ast.tokencode == 43 || ast.tokencode == 45) && TTypeName.searchTypeByName(lcprevsolidtoken.toString()) != null && lcprevsolidtoken.tokencode != 416) {
                lcprevsolidtoken.tokencode = 536;
            }
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (this.gcurrentsqlstatement != null) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                        }
                        if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                            ast.tokentype = ETokenType.ttsimplecomment;
                            ast.tokencode = 258;
                            break;
                        }
                        break;
                    } else {
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (this.gcurrentsqlstatement == null) {
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        if (!this.gcurrentsqlstatement.isdatabricksplsql()) {
                            gst = EFindSqlStateType.stsql;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        gst = EFindSqlStateType.ststoredprocedure;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        foundEnd = false;
                        if (ast.tokencode == 351 || ast.tokencode == 479 || ast.searchToken(479, 4) != null) {
                            waitingEnd = 1;
                            break;
                        }
                        break;
                    }
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (this.sourcetokenlist.sqlplusaftercurtoken()) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case ststoredprocedure: {
                    if (ast.tokencode == 351) {
                        ++waitingEnd;
                    } else if (ast.tokencode == 305) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 316) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 490) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 313) {
                        foundEnd = true;
                        if (--waitingEnd < 0) {
                            waitingEnd = 0;
                        }
                    }
                    if (ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    } else if (ast.tokentype == ETokenType.ttperiod && this.sourcetokenlist.returnaftercurtoken(false) && this.sourcetokenlist.returnbeforecurtoken(false)) {
                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    } else {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokentype == ETokenType.ttsemicolon && waitingEnd == 0 && foundEnd) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        }
                    }
                    if (ast.tokencode != 273) {
                        break;
                    }
                    final int m = this.flexer.getkeywordvalue(ast.astext);
                    if (m != 0) {
                        ast.tokencode = m;
                        break;
                    }
                    ast.tokencode = 264;
                    break;
                }
            }
        }
        if (this.gcurrentsqlstatement != null && (gst == EFindSqlStateType.stsqlplus || gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return this.syntaxErrors.size();
    }

    int doprestogetrawsqlstatements() {
        int waitingEnd = 0;
        boolean foundEnd = false;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (this.gcurrentsqlstatement != null) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                        }
                        if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                            ast.tokentype = ETokenType.ttsimplecomment;
                            ast.tokencode = 258;
                            break;
                        }
                        break;
                    } else {
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (this.gcurrentsqlstatement == null) {
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        if (!this.gcurrentsqlstatement.isprestoplsql()) {
                            gst = EFindSqlStateType.stsql;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        gst = EFindSqlStateType.ststoredprocedure;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        foundEnd = false;
                        if (ast.tokencode == 351 || ast.tokencode == 479 || ast.searchToken(479, 4) != null) {
                            waitingEnd = 1;
                            break;
                        }
                        break;
                    }
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (this.sourcetokenlist.sqlplusaftercurtoken()) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case ststoredprocedure: {
                    if (ast.tokencode == 351) {
                        ++waitingEnd;
                    } else if (ast.tokencode == 305) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 316) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 490) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 313) {
                        foundEnd = true;
                        if (--waitingEnd < 0) {
                            waitingEnd = 0;
                        }
                    }
                    if (ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    } else if (ast.tokentype == ETokenType.ttperiod && this.sourcetokenlist.returnaftercurtoken(false) && this.sourcetokenlist.returnbeforecurtoken(false)) {
                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    } else {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokentype == ETokenType.ttsemicolon && waitingEnd == 0 && foundEnd) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        }
                    }
                    if (ast.tokencode != 273) {
                        break;
                    }
                    final int m = this.flexer.getkeywordvalue(ast.astext);
                    if (m != 0) {
                        ast.tokencode = m;
                        break;
                    }
                    ast.tokencode = 264;
                    break;
                }
            }
        }
        if (this.gcurrentsqlstatement != null && (gst == EFindSqlStateType.stsqlplus || gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return this.syntaxErrors.size();
    }

    public void setSinglePLBlock(final boolean singlePLBlock) {
        this.isSinglePLBlock = singlePLBlock;
    }

    String findPkgName(TSourceToken st, final int mode) {
        String pkgName = "";
        boolean inpkgname = false;
        if (mode == 3) {
            inpkgname = true;
        }
        final int MAX_TRY_TOKENS = 20;
        int tryTokens = 0;
        while (st != null) {
            if (st.isnonsolidtoken()) {
                st = st.getNextTokenInChain();
            } else {
                ++tryTokens;
                if (mode == 1 && st.tokencode == 479) {
                    inpkgname = true;
                    st = st.getNextTokenInChain();
                } else if (mode == 2 && st.tokencode == 526) {
                    inpkgname = true;
                    st = st.getNextTokenInChain();
                } else {
                    if (mode == 1 || mode == 2) {
                        if (st.tokencode == 525) {
                            break;
                        }
                        if (st.tokencode == 341) {
                            break;
                        }
                    }
                    if (mode == 3 && st.tokencode == 59) {
                        break;
                    }
                    if (!inpkgname) {
                        st = st.getNextTokenInChain();
                    } else {
                        pkgName += st.toString();
                        st = st.getNextTokenInChain();
                        if (tryTokens > MAX_TRY_TOKENS) {
                            TBaseType.log(String.format("Package name is not found in create package", new Object[0]), 1, st);
                            break;
                        }
                        continue;
                    }
                }
            }
        }
        return pkgName;
    }

    int doansigetrawsqlstatements() {
        return this.dodb2getrawsqlstatements();
    }

    int dogaussdbgetrawsqlstatements() {
        int waitingEnd = 0;
        boolean foundEnd = false;
        boolean enterDeclare = false;
        this.isOracleStyleRoutine = true;
        this.stProcedure = null;
        this.stFunction = null;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (this.isSinglePLBlock) {
                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
            } else {
                if (ast.tokencode == 298) {
                    final TSourceToken stConstant = ast.searchToken(262, 1);
                    if (stConstant == null) {
                        ast.tokencode = 264;
                    }
                } else if (ast.tokencode == 553) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1 != null && st1.tokencode == 40) {
                        ast.tokencode = 552;
                    }
                } else if (ast.tokencode == 559) {
                    final TSourceToken lcprevst = this.getprevsolidtoken(ast);
                    if (lcprevst != null && lcprevst.tokencode == 311) {
                        final TSourceToken lcnextst = ast.nextSolidToken();
                        if (lcnextst == null || lcnextst.tokencode != 341) {
                            lcprevst.tokencode = 558;
                        }
                    }
                } else if (ast.tokencode == 560) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1 != null) {
                        if (st1.tokencode != 40) {
                            ast.tokencode = 264;
                        }
                    }
                } else if (ast.tokencode == 613) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1 != null && st1.tokencode == 63) {
                        st1.tokencode = 611;
                    }
                } else if (ast.tokencode == 63) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1 != null && st1.tokencode == 262) {
                        ast.tokencode = 611;
                    }
                } else if (ast.tokencode == 326) {
                    final TSourceToken stParen = ast.searchToken(40, 1);
                    if (stParen != null) {
                        final TSourceToken stInsert = ast.searchToken(302, -ast.posinlist);
                        if (stInsert != null) {
                            final TSourceToken stSemiColon = ast.searchToken(59, -ast.posinlist);
                            if (stSemiColon == null || stSemiColon.posinlist <= stInsert.posinlist) {
                                final TSourceToken stFrom = ast.searchToken(329, -ast.posinlist);
                                if (stFrom == null || stFrom.posinlist <= stInsert.posinlist) {
                                    ast.tokencode = 554;
                                }
                            }
                        }
                    }
                }
                switch (gst) {
                    case sterror: {
                        if (ast.tokentype == ETokenType.ttsemicolon) {
                            this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            gst = EFindSqlStateType.stnormal;
                            break;
                        }
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        break;
                    }
                    case stnormal: {
                        if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                            if (this.gcurrentsqlstatement != null) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                            }
                            if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                                ast.tokentype = ETokenType.ttsimplecomment;
                                ast.tokencode = 258;
                                break;
                            }
                            break;
                        } else {
                            if (ast.tokencode == 273) {
                                gst = EFindSqlStateType.stsqlplus;
                                (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                                break;
                            }
                            this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                            if (this.gcurrentsqlstatement == null) {
                                this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                                ast.tokentype = ETokenType.tttokenlizererrortoken;
                                gst = EFindSqlStateType.sterror;
                                this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                                this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            enterDeclare = false;
                            if (!this.gcurrentsqlstatement.isGaussDBStoredProcedure()) {
                                gst = EFindSqlStateType.stsql;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstplsql_createpackage) {
                                gst = EFindSqlStateType.stGaussDBPkgSpec;
                                final TPlsqlCreatePackage pkgspec = (TPlsqlCreatePackage) this.gcurrentsqlstatement;
                                pkgspec.setPackageNameStr(this.findPkgName(ast.getNextTokenInChain(), 1));
                                break;
                            }
                            if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstoraclecreatepackagebody) {
                                gst = EFindSqlStateType.stGaussDBPkgBody;
                                final TPlsqlCreatePackage pkgspec = (TPlsqlCreatePackage) this.gcurrentsqlstatement;
                                pkgspec.setPackageNameStr(this.findPkgName(ast.getNextTokenInChain(), 2));
                                break;
                            }
                            gst = EFindSqlStateType.ststoredprocedure;
                            foundEnd = false;
                            if (ast.tokencode == 351 || ast.tokencode == 479 || ast.searchToken(479, 4) != null) {
                                waitingEnd = 1;
                            } else if (ast.tokencode == 315) {
                                enterDeclare = true;
                            }
                            if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstcreateprocedure) {
                                this.stProcedure = ast.searchToken(477, 3);
                                break;
                            }
                            if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstcreatefunction) {
                                this.stFunction = ast.searchToken(478, 3);
                                break;
                            }
                            break;
                        }
                    }
                    case stsqlplus: {
                        if (ast.insqlpluscmd) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    case stsql: {
                        if (ast.tokentype == ETokenType.ttsemicolon) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            this.gcurrentsqlstatement.semicolonended = ast;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        if (this.sourcetokenlist.sqlplusaftercurtoken()) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        if (ast.tokencode == 258 && ast.toString().trim().endsWith(TBaseType.sqlflow_stmt_delimiter_str)) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                    case ststoredprocedure: {
                        if (ast.tokencode == 623) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            this.isOracleStyleRoutine = false;
                            gst = EFindSqlStateType.ststoredprocedurePgStartBody;
                            break;
                        }
                        if (ast.tokencode == 624) {
                            final TSourceToken nextSt = ast.nextSolidToken();
                            if (nextSt != null && this.gcurrentsqlstatement instanceof TRoutine) {
                                final TRoutine p = (TRoutine) this.gcurrentsqlstatement;
                                p.setRoutineLanguage(nextSt.toString());
                                this.isOracleStyleRoutine = false;
                            }
                        }
                        if (ast.tokentype == ETokenType.ttsemicolon && waitingEnd == 0 && !enterDeclare) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            this.gcurrentsqlstatement.semicolonended = ast;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        if (ast.tokencode == 351) {
                            ++waitingEnd;
                            enterDeclare = false;
                        } else if (ast.tokencode == 315 || ast.tokencode == 341 || ast.tokencode == 525) {
                            final TSourceToken next = ast.nextSolidToken();
                            if (next == null || next.tokencode != 262) {
                                enterDeclare = true;
                            }
                        } else if (ast.tokencode == 305) {
                            if (ast.searchToken(313, -1) == null) {
                                ++waitingEnd;
                            }
                        } else if (ast.tokencode == 316) {
                            if (ast.searchToken(313, -1) == null) {
                                ++waitingEnd;
                            }
                        } else if (ast.tokencode == 490) {
                            if (ast.searchToken(313, -1) == null) {
                                ++waitingEnd;
                            }
                        } else if (ast.tokencode == 313) {
                            foundEnd = true;
                            if (--waitingEnd < 0) {
                                waitingEnd = 0;
                            }
                        }
                        if (ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                            ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        } else if (ast.tokentype == ETokenType.ttperiod && this.sourcetokenlist.returnaftercurtoken(false) && this.sourcetokenlist.returnbeforecurtoken(false)) {
                            ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        } else {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            if (ast.tokentype == ETokenType.ttsemicolon && waitingEnd == 0 && foundEnd) {
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            }
                        }
                        if (ast.tokencode == 273) {
                            final int m = this.flexer.getkeywordvalue(ast.astext);
                            if (m != 0) {
                                ast.tokencode = m;
                            } else {
                                ast.tokencode = 264;
                            }
                        }
                        if (gst == EFindSqlStateType.ststoredprocedure && ast.tokencode == 258 && ast.toString().trim().endsWith(TBaseType.sqlflow_stmt_delimiter_str)) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        break;
                    }
                    case ststoredprocedurePgStartBody: {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokencode == 623) {
                            gst = EFindSqlStateType.ststoredprocedurePgEndBody;
                            break;
                        }
                        break;
                    }
                    case ststoredprocedurePgEndBody: {
                        if (ast.tokentype == ETokenType.ttsemicolon) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            this.gcurrentsqlstatement.semicolonended = ast;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        if (ast.tokencode == 258 && ast.toString().trim().endsWith(TBaseType.sqlflow_stmt_delimiter_str)) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokencode == 624) {
                            final TSourceToken nextSt = ast.nextSolidToken();
                            if (nextSt != null && this.gcurrentsqlstatement instanceof TRoutine) {
                                final TRoutine p = (TRoutine) this.gcurrentsqlstatement;
                                p.setRoutineLanguage(nextSt.toString());
                            }
                            break;
                        }
                        break;
                    }
                    case stGaussDBPkgSpec: {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokencode == 313) {
                            final TPlsqlCreatePackage plsqlCreatePackage = (TPlsqlCreatePackage) this.gcurrentsqlstatement;
                            final String pkgName = this.findPkgName(ast.getNextTokenInChain(), 3);
                            if (pkgName != null && pkgName.equalsIgnoreCase(plsqlCreatePackage.getPackageNameStr())) {
                                gst = EFindSqlStateType.stGaussDBPkgSpecEnd;
                            }
                            break;
                        }
                        break;
                    }
                    case stGaussDBPkgSpecEnd: {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokencode == 59) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        break;
                    }
                    case stGaussDBPkgBody: {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokencode == 313) {
                            final TPlsqlCreatePackage plsqlCreatePackage = (TPlsqlCreatePackage) this.gcurrentsqlstatement;
                            final String pkgName = this.findPkgName(ast.getNextTokenInChain(), 3);
                            if (pkgName != null && pkgName.equalsIgnoreCase(plsqlCreatePackage.getPackageNameStr())) {
                                gst = EFindSqlStateType.stGaussDBPkgBodyEnd;
                            }
                            break;
                        }
                        break;
                    }
                    case stGaussDBPkgBodyEnd: {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokencode == 59) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        break;
                    }
                }
            }
        }
        if (this.gcurrentsqlstatement != null && (gst == EFindSqlStateType.stsqlplus || gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.ststoredprocedurePgEndBody || gst == EFindSqlStateType.sterror || this.isSinglePLBlock)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return this.syntaxErrors.size();
    }

    int dopostgresqlgetrawsqlstatements() {
        int waitingEnd = 0;
        boolean foundEnd = false;
        boolean enterDeclare = false;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        if (this.isSinglePLBlock) {
            this.gcurrentsqlstatement = new TCommonBlock(EDbVendor.dbvpostgresql);
        }
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (this.isSinglePLBlock) {
                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
            } else {
                if (ast.tokencode == 298) {
                    final TSourceToken stConstant = ast.searchToken(262, 1);
                    if (stConstant == null) {
                        ast.tokencode = 264;
                    }
                } else if (ast.tokencode == 553) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1 != null && st1.tokencode == 40) {
                        ast.tokencode = 552;
                    }
                } else if (ast.tokencode == 559) {
                    final TSourceToken lcprevst = this.getprevsolidtoken(ast);
                    if (lcprevst != null && lcprevst.tokencode == 311) {
                        final TSourceToken lcnextst = ast.nextSolidToken();
                        if (lcnextst == null || lcnextst.tokencode != 341) {
                            lcprevst.tokencode = 558;
                        }
                    }
                } else if (ast.tokencode == 560) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1 != null) {
                        if (st1.tokencode != 40) {
                            ast.tokencode = 264;
                        }
                    }
                } else if (ast.tokencode == 613) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1 != null && st1.tokencode == 63) {
                        st1.tokencode = 611;
                    }
                } else if (ast.tokencode == 63) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1 != null && st1.tokencode == 262) {
                        ast.tokencode = 611;
                    }
                } else if (ast.tokencode == 326) {
                    final TSourceToken stParen = ast.searchToken(40, 1);
                    if (stParen != null) {
                        final TSourceToken stInsert = ast.searchToken(302, -ast.posinlist);
                        if (stInsert != null) {
                            final TSourceToken stSemiColon = ast.searchToken(59, -ast.posinlist);
                            if (stSemiColon == null || stSemiColon.posinlist <= stInsert.posinlist) {
                                final TSourceToken stFrom = ast.searchToken(329, -ast.posinlist);
                                if (stFrom == null || stFrom.posinlist <= stInsert.posinlist) {
                                    ast.tokencode = 554;
                                }
                            }
                        }
                    }
                }
                switch (gst) {
                    case sterror: {
                        if (ast.tokentype == ETokenType.ttsemicolon) {
                            this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            gst = EFindSqlStateType.stnormal;
                            break;
                        }
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        break;
                    }
                    case stnormal: {
                        if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                            if (this.gcurrentsqlstatement != null) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                            }
                            if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                                ast.tokentype = ETokenType.ttsimplecomment;
                                ast.tokencode = 258;
                                break;
                            }
                            break;
                        } else {
                            if (ast.tokencode == 273) {
                                gst = EFindSqlStateType.stsqlplus;
                                (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                                break;
                            }
                            this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                            if (this.gcurrentsqlstatement == null) {
                                this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                                ast.tokentype = ETokenType.tttokenlizererrortoken;
                                gst = EFindSqlStateType.sterror;
                                this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                                this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            enterDeclare = false;
                            if (!this.gcurrentsqlstatement.ispgplsql()) {
                                gst = EFindSqlStateType.stsql;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            gst = EFindSqlStateType.ststoredprocedure;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            foundEnd = false;
                            if (ast.tokencode == 351 || ast.tokencode == 479 || ast.searchToken(479, 4) != null) {
                                waitingEnd = 1;
                                break;
                            }
                            if (ast.tokencode == 315) {
                                enterDeclare = true;
                                break;
                            }
                            break;
                        }
                    }
                    case stsqlplus: {
                        if (ast.insqlpluscmd) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    case stsql: {
                        if (ast.tokentype == ETokenType.ttsemicolon) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            this.gcurrentsqlstatement.semicolonended = ast;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        if (this.sourcetokenlist.sqlplusaftercurtoken()) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        if (ast.tokencode == 258 && ast.toString().trim().endsWith(TBaseType.sqlflow_stmt_delimiter_str)) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                    case ststoredprocedure: {
                        if (ast.tokencode == 623) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            gst = EFindSqlStateType.ststoredprocedurePgStartBody;
                            break;
                        }
                        if (ast.tokencode == 624) {
                            final TSourceToken nextSt = ast.nextSolidToken();
                            if (nextSt != null && this.gcurrentsqlstatement instanceof TRoutine) {
                                final TRoutine p = (TRoutine) this.gcurrentsqlstatement;
                                p.setRoutineLanguage(nextSt.toString());
                            }
                        }
                        if (ast.tokentype == ETokenType.ttsemicolon && waitingEnd == 0 && !enterDeclare) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            this.gcurrentsqlstatement.semicolonended = ast;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        if (ast.tokencode == 351) {
                            ++waitingEnd;
                            enterDeclare = false;
                        } else if (ast.tokencode == 315) {
                            enterDeclare = true;
                        } else if (ast.tokencode == 305) {
                            if (ast.searchToken(313, -1) == null) {
                                ++waitingEnd;
                            }
                        } else if (ast.tokencode == 316) {
                            if (ast.searchToken(313, -1) == null) {
                                ++waitingEnd;
                            }
                        } else if (ast.tokencode == 490) {
                            if (ast.searchToken(313, -1) == null) {
                                ++waitingEnd;
                            }
                        } else if (ast.tokencode == 313) {
                            foundEnd = true;
                            if (--waitingEnd < 0) {
                                waitingEnd = 0;
                            }
                        }
                        if (ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                            ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        } else if (ast.tokentype == ETokenType.ttperiod && this.sourcetokenlist.returnaftercurtoken(false) && this.sourcetokenlist.returnbeforecurtoken(false)) {
                            ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        } else {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            if (ast.tokentype == ETokenType.ttsemicolon && waitingEnd == 0 && foundEnd) {
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            }
                        }
                        if (ast.tokencode == 273) {
                            final int m = this.flexer.getkeywordvalue(ast.astext);
                            if (m != 0) {
                                ast.tokencode = m;
                            } else {
                                ast.tokencode = 264;
                            }
                        }
                        if (gst == EFindSqlStateType.ststoredprocedure && ast.tokencode == 258 && ast.toString().trim().endsWith(TBaseType.sqlflow_stmt_delimiter_str)) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        break;
                    }
                    case ststoredprocedurePgStartBody: {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokencode == 623) {
                            gst = EFindSqlStateType.ststoredprocedurePgEndBody;
                            break;
                        }
                        break;
                    }
                    case ststoredprocedurePgEndBody: {
                        if (ast.tokentype == ETokenType.ttsemicolon) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            this.gcurrentsqlstatement.semicolonended = ast;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        if (ast.tokencode == 258 && ast.toString().trim().endsWith(TBaseType.sqlflow_stmt_delimiter_str)) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokencode != 624) {
                            break;
                        }
                        final TSourceToken nextSt = ast.nextSolidToken();
                        if (nextSt != null && this.gcurrentsqlstatement instanceof TRoutine) {
                            final TRoutine p = (TRoutine) this.gcurrentsqlstatement;
                            p.setRoutineLanguage(nextSt.toString());
                            break;
                        }
                        break;
                    }
                }
            }
        }
        if (this.gcurrentsqlstatement != null && (gst == EFindSqlStateType.stsqlplus || gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.ststoredprocedurePgEndBody || gst == EFindSqlStateType.sterror || this.isSinglePLBlock)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return this.syntaxErrors.size();
    }

    void explandDollarString() {
        final ArrayList<TSourceToken> dollarTokens = new ArrayList<TSourceToken>();
        boolean isSQLLanguage = true;
        for (int i = 0; i < this.sqlstatements.size(); ++i) {
            final TCustomSqlStatement sql = this.sqlstatements.get(i);
            if (sql.sqlstatementtype == ESqlStatementType.sstcreateprocedure) {
                isSQLLanguage = true;
                for (int j = 0; j < sql.sourcetokenlist.size(); ++j) {
                    final TSourceToken st = sql.sourcetokenlist.get(j);
                    if (sql.sqlstatementtype == ESqlStatementType.sstcreateprocedure && st.tokencode == 545) {
                        final TSourceToken lang = st.nextSolidToken();
                        if (lang != null && !lang.toString().equalsIgnoreCase("sql")) {
                            isSQLLanguage = false;
                        }
                    }
                    if (!isSQLLanguage) {
                        break;
                    }
                    if (st.tokencode == 262 && st.toString().startsWith("$$")) {
                        dollarTokens.add(st);
                    }
                }
                for (int m = dollarTokens.size() - 1; m >= 0; --m) {
                    final TSourceToken st = dollarTokens.get(m);
                    final TGSqlParser parser = new TGSqlParser(this.dbVendor);
                    parser.sqltext = TBaseType.stringBlock((int) st.lineNo - 1, (int) st.columnNo) + TBaseType.getStringInsideLiteral(st.toString());
                    parser.tokenizeSqltext();
                    boolean isValidBlock = false;
                    int k = 0;
                    while (k < parser.sourcetokenlist.size()) {
                        final TSourceToken st2 = parser.sourcetokenlist.get(k);
                        if (st2.isnonsolidtoken()) {
                            ++k;
                        } else {
                            if (st2.tokencode == 315 || st2.tokencode == 351) {
                                isValidBlock = true;
                                break;
                            }
                            break;
                        }
                    }
                    if (isValidBlock) {
                        TSourceToken semiColon = null;
                        st.tokenstatus = ETokenStatus.tsdeleted;
                        for (int l = 0; l < parser.sourcetokenlist.size(); ++l) {
                            final TSourceToken st2 = parser.sourcetokenlist.get(l);
                            if (st2.tokencode == 59) {
                                semiColon = st2;
                            }
                            sql.sourcetokenlist.add(st.posinlist++, st2);
                        }
                        if (semiColon != null && semiColon.prevSolidToken().tokencode == 313) {
                            semiColon.tokenstatus = ETokenStatus.tsdeleted;
                        }
                    }
                }
                dollarTokens.clear();
            }
        }
    }

    int dosnowflakegetrawsqlstatements() {
        final int waitingEnd = 0;
        final boolean foundEnd = false;
        final int[] waitingEnds = new int[1024];
        final stored_procedure_type[] sptype = new stored_procedure_type[1024];
        final stored_procedure_status[] procedure_status = new stored_procedure_status[1024];
        boolean endBySlashOnly = true;
        int nestedProcedures = 0;
        final int nestedParenthesis = 0;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode == 344 || ast.tokencode == 343) {
                final TSourceToken stLparen = ast.searchToken(40, 1);
                if (stLparen != null) {
                    ast.tokencode = 264;
                }
            } else if (ast.tokencode == 538) {
                final TSourceToken stLparen = ast.searchToken(40, 1);
                if (stLparen != null) {
                    ast.tokencode = 539;
                }
            } else if (ast.tokencode == 394) {
                TSourceToken stLparen = ast.searchToken(40, 1);
                if (stLparen != null) {
                    ast.tokencode = 541;
                } else {
                    stLparen = ast.searchToken(46, 1);
                    if (stLparen != null) {
                        ast.tokencode = 264;
                    }
                }
            } else if (ast.tokencode == 393) {
                TSourceToken stLparen = ast.searchToken(40, 1);
                if (stLparen != null) {
                    ast.tokencode = 542;
                } else {
                    stLparen = ast.searchToken(46, 1);
                    if (stLparen != null) {
                        ast.tokencode = 264;
                    }
                }
            } else if (ast.tokencode == 379) {
                TSourceToken stLparen = ast.searchToken(40, 1);
                if (stLparen != null) {
                    ast.tokencode = 543;
                } else {
                    stLparen = ast.searchToken(46, 1);
                    if (stLparen != null) {
                        ast.tokencode = 264;
                    }
                }
            } else if (ast.tokencode == 548) {
                final TSourceToken stAs = ast.searchToken(341, 2);
                if (stAs != null) {
                    ast.tokencode = 549;
                }
            } else if (ast.tokencode == 550 || ast.tokencode == 551) {
                final TSourceToken stLparen = ast.searchToken(40, 1);
                if (stLparen == null) {
                    ast.tokencode = 264;
                }
            }
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (this.gcurrentsqlstatement != null) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                        }
                        if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                            ast.tokentype = ETokenType.ttsimplecomment;
                            ast.tokencode = 258;
                            break;
                        }
                        break;
                    } else {
                        if (ast.tokencode == 273) {
                            gst = EFindSqlStateType.stsqlplus;
                            (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                            break;
                        }
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (this.gcurrentsqlstatement == null) {
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        if (!this.gcurrentsqlstatement.issnowflakeplsql()) {
                            gst = EFindSqlStateType.stsql;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        nestedProcedures = 0;
                        gst = EFindSqlStateType.ststoredprocedure;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        switch (this.gcurrentsqlstatement.sqlstatementtype) {
                            case sstplsql_createprocedure:
                            case sstcreateprocedure: {
                                sptype[nestedProcedures] = stored_procedure_type.procedure;
                                break;
                            }
                            case sstplsql_createfunction: {
                                sptype[nestedProcedures] = stored_procedure_type.function;
                                break;
                            }
                            case sstplsql_createpackage: {
                                sptype[nestedProcedures] = stored_procedure_type.package_spec;
                                if (ast.searchToken(526, 5) != null) {
                                    sptype[nestedProcedures] = stored_procedure_type.package_body;
                                    break;
                                }
                                break;
                            }
                            case sst_plsql_block: {
                                sptype[nestedProcedures] = stored_procedure_type.block_with_declare;
                                if (ast.tokencode == 351) {
                                    sptype[nestedProcedures] = stored_procedure_type.block_with_begin;
                                    break;
                                }
                                break;
                            }
                            case sstplsql_createtrigger: {
                                sptype[nestedProcedures] = stored_procedure_type.create_trigger;
                                break;
                            }
                            case sstoraclecreatelibrary: {
                                sptype[nestedProcedures] = stored_procedure_type.create_library;
                                break;
                            }
                            case sstplsql_createtype_placeholder: {
                                gst = EFindSqlStateType.stsql;
                                break;
                            }
                            default: {
                                sptype[nestedProcedures] = stored_procedure_type.others;
                                break;
                            }
                        }
                        if (sptype[0] == stored_procedure_type.block_with_declare) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.is_as;
                        } else if (sptype[0] == stored_procedure_type.block_with_begin) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.body;
                        } else if (sptype[0] == stored_procedure_type.procedure) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.start;
                        } else if (sptype[0] == stored_procedure_type.function) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.start;
                        } else if (sptype[0] == stored_procedure_type.package_spec) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.start;
                        } else if (sptype[0] == stored_procedure_type.package_body) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.start;
                        } else if (sptype[0] == stored_procedure_type.create_trigger) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.start;
                        } else if (sptype[0] == stored_procedure_type.create_library) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.bodyend;
                        } else {
                            endBySlashOnly = true;
                            procedure_status[0] = stored_procedure_status.bodyend;
                        }
                        if (ast.tokencode == 351 || ast.tokencode == 479 || ast.searchToken(479, 4) != null) {
                            waitingEnds[nestedProcedures] = 1;
                            break;
                        }
                        break;
                    }
                }
                case stsqlplus: {
                    if (ast.insqlpluscmd) {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                    gst = EFindSqlStateType.stnormal;
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    break;
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (this.sourcetokenlist.sqlplusaftercurtoken()) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case ststoredprocedure: {
                    if (procedure_status[nestedProcedures] != stored_procedure_status.bodyend) {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                    }
                    switch (procedure_status[nestedProcedures]) {
                        case start: {
                            if (ast.tokencode == 341 || ast.tokencode == 525) {
                                if (sptype[nestedProcedures] == stored_procedure_type.create_trigger) {
                                    break;
                                }
                                if (sptype[0] == stored_procedure_type.package_spec && nestedProcedures > 0) {
                                    break;
                                }
                                procedure_status[nestedProcedures] = stored_procedure_status.is_as;
                                if (ast.searchToken("language", 1) == null) {
                                    break;
                                }
                                if (nestedProcedures == 0) {
                                    gst = EFindSqlStateType.stsql;
                                    break;
                                }
                                procedure_status[nestedProcedures] = stored_procedure_status.body;
                                --nestedProcedures;
                                break;
                            } else {
                                if (ast.tokencode == 351) {
                                    if (sptype[nestedProcedures] == stored_procedure_type.create_trigger) {
                                        final int[] array = waitingEnds;
                                        final int n = nestedProcedures;
                                        ++array[n];
                                    }
                                    if (nestedProcedures > 0) {
                                        --nestedProcedures;
                                    }
                                    procedure_status[nestedProcedures] = stored_procedure_status.body;
                                    break;
                                }
                                if (ast.tokencode == 313) {
                                    if (nestedProcedures > 0 && waitingEnds[nestedProcedures - 1] == 1 && (sptype[nestedProcedures - 1] == stored_procedure_type.package_body || sptype[nestedProcedures - 1] == stored_procedure_type.package_spec)) {
                                        --nestedProcedures;
                                        procedure_status[nestedProcedures] = stored_procedure_status.bodyend;
                                        break;
                                    }
                                    break;
                                } else if (ast.tokencode == 477 || ast.tokencode == 478) {
                                    if (nestedProcedures > 0 && waitingEnds[nestedProcedures] == 0 && procedure_status[nestedProcedures - 1] == stored_procedure_status.is_as) {
                                        --nestedProcedures;
                                        ++nestedProcedures;
                                        waitingEnds[nestedProcedures] = 0;
                                        procedure_status[nestedProcedures] = stored_procedure_status.start;
                                        break;
                                    }
                                    break;
                                } else {
                                    if (sptype[nestedProcedures] == stored_procedure_type.create_trigger && ast.tokencode == 315) {
                                        procedure_status[nestedProcedures] = stored_procedure_status.is_as;
                                        break;
                                    }
                                    if (sptype[nestedProcedures] == stored_procedure_type.create_trigger && ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                                        gst = EFindSqlStateType.stnormal;
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        break;
                                    }
                                    if (sptype[nestedProcedures] == stored_procedure_type.create_trigger) {
                                        if (ast.tokencode == 545) {
                                            final TSourceToken compoundSt = ast.searchToken(560, -1);
                                            if (compoundSt != null) {
                                                procedure_status[nestedProcedures] = stored_procedure_status.body;
                                                final int[] array2 = waitingEnds;
                                                final int n2 = nestedProcedures;
                                                ++array2[n2];
                                            }
                                            break;
                                        }
                                        break;
                                    } else if (sptype[nestedProcedures] == stored_procedure_type.function && ast.tokencode == 528) {
                                        if (ast.searchToken("aggregate", -1) == null && ast.searchToken("pipelined", -1) == null) {
                                            break;
                                        }
                                        if (nestedProcedures == 0) {
                                            gst = EFindSqlStateType.stsql;
                                            break;
                                        }
                                        procedure_status[nestedProcedures] = stored_procedure_status.body;
                                        --nestedProcedures;
                                        break;
                                    } else {
                                        if (ast.tokencode == 545) {
                                            final TSourceToken nextSt = ast.nextSolidToken();
                                            if (nextSt != null && this.gcurrentsqlstatement instanceof TRoutine) {
                                                final TRoutine p = (TRoutine) this.gcurrentsqlstatement;
                                                p.setRoutineLanguage(nextSt.toString());
                                                if (p.getRoutineLanguage().toString().equalsIgnoreCase("javascript")) {
                                                    gst = EFindSqlStateType.stsql;
                                                }
                                            }
                                            break;
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                        case is_as: {
                            if (ast.tokencode == 477 || ast.tokencode == 478) {
                                ++nestedProcedures;
                                waitingEnds[nestedProcedures] = 0;
                                procedure_status[nestedProcedures] = stored_procedure_status.start;
                                if (nestedProcedures > 1023) {
                                    gst = EFindSqlStateType.sterror;
                                    --nestedProcedures;
                                    break;
                                }
                                break;
                            } else {
                                if (ast.tokencode == 351) {
                                    Label_2273:
                                    {
                                        if (nestedProcedures == 0) {
                                            if (sptype[nestedProcedures] == stored_procedure_type.package_body) {
                                                break Label_2273;
                                            }
                                            if (sptype[nestedProcedures] == stored_procedure_type.package_spec) {
                                                break Label_2273;
                                            }
                                        }
                                        final int[] array3 = waitingEnds;
                                        final int n3 = nestedProcedures;
                                        ++array3[n3];
                                    }
                                    procedure_status[nestedProcedures] = stored_procedure_status.body;
                                    break;
                                }
                                if (ast.tokencode == 313) {
                                    if (nestedProcedures == 0 && waitingEnds[nestedProcedures] == 1 && (sptype[nestedProcedures] == stored_procedure_type.package_body || sptype[nestedProcedures] == stored_procedure_type.package_spec)) {
                                        procedure_status[nestedProcedures] = stored_procedure_status.bodyend;
                                        final int[] array4 = waitingEnds;
                                        final int n4 = nestedProcedures;
                                        --array4[n4];
                                        break;
                                    }
                                    final int[] array5 = waitingEnds;
                                    final int n5 = nestedProcedures;
                                    --array5[n5];
                                    break;
                                } else {
                                    if (ast.tokencode == 316 && ast.searchToken(59, 1) == null) {
                                        final int[] array6 = waitingEnds;
                                        final int n6 = nestedProcedures;
                                        ++array6[n6];
                                        break;
                                    }
                                    break;
                                }
                            }
                        }
                        case body: {
                            if (ast.tokencode == 351) {
                                final int[] array7 = waitingEnds;
                                final int n7 = nestedProcedures;
                                ++array7[n7];
                                break;
                            }
                            if (ast.tokencode == 305) {
                                if (ast.searchToken(59, 2) == null) {
                                    final int[] array8 = waitingEnds;
                                    final int n8 = nestedProcedures;
                                    ++array8[n8];
                                    break;
                                }
                                break;
                            } else if (ast.tokencode == 316) {
                                if (ast.searchToken(59, 2) == null && ast.searchToken(313, -1) == null) {
                                    final int[] array9 = waitingEnds;
                                    final int n9 = nestedProcedures;
                                    ++array9[n9];
                                    break;
                                }
                                break;
                            } else if (ast.tokencode == 490) {
                                if (ast.searchToken(313, -1) == null || ast.searchToken(59, 2) == null) {
                                    final int[] array10 = waitingEnds;
                                    final int n10 = nestedProcedures;
                                    ++array10[n10];
                                    break;
                                }
                                break;
                            } else if (ast.tokencode == 313) {
                                final int[] array11 = waitingEnds;
                                final int n11 = nestedProcedures;
                                --array11[n11];
                                if (waitingEnds[nestedProcedures] != 0) {
                                    break;
                                }
                                if (nestedProcedures == 0) {
                                    procedure_status[nestedProcedures] = stored_procedure_status.bodyend;
                                    break;
                                }
                                --nestedProcedures;
                                procedure_status[nestedProcedures] = stored_procedure_status.is_as;
                                break;
                            } else {
                                if (waitingEnds[nestedProcedures] == 0 && ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                                    ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                                    gst = EFindSqlStateType.stnormal;
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    break;
                                }
                                break;
                            }
                        }
                        case bodyend: {
                            if (ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                                ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.tokentype == ETokenType.ttperiod && this.sourcetokenlist.returnaftercurtoken(false) && this.sourcetokenlist.returnbeforecurtoken(false)) {
                                ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(479, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(477, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(478, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(307, 1) != null && ast.searchToken(479, 4) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(307, 1) != null && ast.searchToken(546, 4) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(426, 1) != null && ast.searchToken(545, 2) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(301, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(419, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(423, 1) != null && ast.searchToken(440, 2) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                    }
                    if (ast.tokencode == 273) {
                        final int m = this.flexer.getkeywordvalue(ast.astext);
                        if (m != 0) {
                            ast.tokencode = m;
                        } else if (ast.tokentype == ETokenType.ttslash) {
                            ast.tokencode = 47;
                        } else {
                            ast.tokencode = 264;
                        }
                    }
                    final int wrapped_keyword_max_pos = 20;
                    if (ast.tokencode != 535 || ast.posinlist - this.gcurrentsqlstatement.sourcetokenlist.get(0).posinlist >= 20) {
                        break;
                    }
                    if (this.gcurrentsqlstatement instanceof TCommonStoredProcedureSqlStatement) {
                        ((TCommonStoredProcedureSqlStatement) this.gcurrentsqlstatement).setWrapped(true);
                    }
                    if (this.gcurrentsqlstatement instanceof TPlsqlCreatePackage && ast.prevSolidToken() != null) {
                        ((TPlsqlCreatePackage) this.gcurrentsqlstatement).setPackageName(this.fparser.getNf().createObjectNameWithPart(ast.prevSolidToken()));
                        break;
                    }
                    break;
                }
            }
        }
        if (this.gcurrentsqlstatement != null && (gst == EFindSqlStateType.stsqlplus || gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return this.syntaxErrors.size();
    }

    int dogreenplumgetrawsqlstatements() {
        int waitingEnd = 0;
        boolean foundEnd = false;
        boolean enterDeclare = false;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        TSourceToken dollarStringToken = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode == 394) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null && st1.tokencode == 40) {
                    ast.tokencode = 552;
                }
            } else if (ast.tokencode == 554) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null && st1.tokencode == 40) {
                    ast.tokencode = 553;
                }
            } else if (ast.tokencode == 557) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null) {
                    if (st1.tokencode != 40) {
                        ast.tokencode = 264;
                    }
                }
            } else if (ast.tokencode == 326) {
                final TSourceToken stParen = ast.searchToken(40, 1);
                if (stParen != null) {
                    final TSourceToken stInsert = ast.searchToken(302, -ast.posinlist);
                    if (stInsert != null) {
                        final TSourceToken stSemiColon = ast.searchToken(59, -ast.posinlist);
                        if (stSemiColon == null || stSemiColon.posinlist <= stInsert.posinlist) {
                            final TSourceToken stFrom = ast.searchToken(329, -ast.posinlist);
                            if (stFrom == null) {
                                ast.tokencode = 558;
                            }
                        }
                    }
                }
            }
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (this.gcurrentsqlstatement != null) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                        }
                        if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                            ast.tokentype = ETokenType.ttsimplecomment;
                            ast.tokencode = 258;
                            break;
                        }
                        break;
                    } else {
                        if (ast.tokencode == 92) {
                            gst = EFindSqlStateType.stsqlplus;
                            (this.gcurrentsqlstatement = new TSlashCommand(this.dbVendor)).addtokentolist(ast);
                            break;
                        }
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (this.gcurrentsqlstatement == null) {
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        if (!this.gcurrentsqlstatement.isgreeplumplsql()) {
                            gst = EFindSqlStateType.stsql;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        gst = EFindSqlStateType.ststoredprocedure;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        foundEnd = false;
                        if (ast.tokencode == 351 || ast.tokencode == 479 || ast.searchToken(479, 4) != null) {
                            waitingEnd = 1;
                            break;
                        }
                        if (ast.tokencode == 315) {
                            enterDeclare = true;
                            break;
                        }
                        break;
                    }
                }
                case stsqlplus: {
                    if (ast.tokencode == 260) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    }
                    if (ast.tokencode != 92) {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                    final TSourceToken nextst = ast.searchToken(92, 1);
                    if (nextst != null) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    gst = EFindSqlStateType.stsqlplus;
                    (this.gcurrentsqlstatement = new TSlashCommand(this.dbVendor)).addtokentolist(ast);
                    break;
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (this.sourcetokenlist.sqlplusaftercurtoken()) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case ststoredprocedure: {
                    if (ast.tokencode == 559) {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        gst = EFindSqlStateType.ststoredprocedurePgStartBody;
                        dollarStringToken = ast;
                        break;
                    }
                    if (ast.tokencode == 549) {
                        final TSourceToken nextSt = ast.nextSolidToken();
                        if (nextSt != null && this.gcurrentsqlstatement instanceof TRoutine) {
                            final TRoutine p = (TRoutine) this.gcurrentsqlstatement;
                            p.setRoutineLanguage(nextSt.toString());
                        }
                    }
                    if (ast.tokentype == ETokenType.ttsemicolon && waitingEnd == 0 && !enterDeclare) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (ast.tokencode == 351) {
                        ++waitingEnd;
                        enterDeclare = false;
                    } else if (ast.tokencode == 315) {
                        enterDeclare = true;
                    } else if (ast.tokencode == 305) {
                        if (ast.searchToken(313, -1) == null && ast.searchToken(556, 1) == null && ast.searchToken(556, 2) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 316) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 490) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 313) {
                        foundEnd = true;
                        if (--waitingEnd < 0) {
                            waitingEnd = 0;
                        }
                    }
                    if (ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    } else if (ast.tokentype == ETokenType.ttperiod && this.sourcetokenlist.returnaftercurtoken(false) && this.sourcetokenlist.returnbeforecurtoken(false)) {
                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    } else if (ast.tokencode == 315 && waitingEnd == 0) {
                        --i;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                    } else {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokentype == ETokenType.ttsemicolon && waitingEnd == 0 && foundEnd && this.gcurrentsqlstatement.OracleStatementCanBeSeparatedByBeginEndPair()) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        }
                    }
                    if (ast.tokencode == 273) {
                        final int m = this.flexer.getkeywordvalue(ast.astext);
                        if (m != 0) {
                            ast.tokencode = m;
                        } else {
                            ast.tokencode = 264;
                        }
                        break;
                    }
                    break;
                }
                case ststoredprocedurePgStartBody: {
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    if (ast.tokencode == 559 && dollarStringToken.toString().equalsIgnoreCase(ast.toString())) {
                        gst = EFindSqlStateType.ststoredprocedurePgEndBody;
                        break;
                    }
                    break;
                }
                case ststoredprocedurePgEndBody: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (ast.tokencode == 258 && ast.toString().trim().endsWith(TBaseType.sqlflow_stmt_delimiter_str)) {
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    if (ast.tokencode != 549) {
                        break;
                    }
                    final TSourceToken nextSt = ast.nextSolidToken();
                    if (nextSt != null && this.gcurrentsqlstatement instanceof TRoutine) {
                        final TRoutine p = (TRoutine) this.gcurrentsqlstatement;
                        p.setRoutineLanguage(nextSt.toString());
                        break;
                    }
                    break;
                }
            }
        }
        if (this.gcurrentsqlstatement != null && (gst == EFindSqlStateType.stsqlplus || gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.ststoredprocedurePgEndBody || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return this.syntaxErrors.size();
    }

    private boolean isTypeCastToken(final TSourceToken ast) {
        boolean istypecasetoken = false;
        final TSourceToken st = ast.searchToken(40, 1);
        if (st != null) {
            final TSourceToken nst = st.searchToken(263, 1);
            istypecasetoken = (nst == null);
        }
        return istypecasetoken;
    }

    int donetezzagetrawsqlstatements() {
        int waitingEnd = 0;
        boolean foundEnd = false;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode == 360) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 532;
                }
            } else if (ast.tokencode == 361) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 533;
                }
            } else if (ast.tokencode == 357) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 534;
                }
            } else if (ast.tokencode == 367) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 535;
                }
            } else if (ast.tokencode == 374) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 536;
                }
            } else if (ast.tokencode == 368) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 537;
                }
            } else if (ast.tokencode == 372) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 538;
                }
            } else if (ast.tokencode == 355) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 540;
                }
            } else if (ast.tokencode == 379) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 541;
                }
            } else if (ast.tokencode == 380) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 542;
                }
            } else if (ast.tokencode == 382) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 543;
                }
            } else if (ast.tokencode == 381) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 544;
                }
            } else if (ast.tokencode == 394) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 545;
                }
            } else if (ast.tokencode == 393) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 546;
                }
            } else if (ast.tokencode == 395) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 547;
                }
            } else if (ast.tokencode == 416) {
                if (this.isTypeCastToken(ast)) {
                    ast.tokencode = 548;
                }
            } else if (ast.tokencode == 375 && this.isTypeCastToken(ast)) {
                ast.tokencode = 549;
            }
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (this.gcurrentsqlstatement != null) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                        }
                        if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                            ast.tokentype = ETokenType.ttsimplecomment;
                            ast.tokencode = 258;
                            break;
                        }
                        break;
                    } else {
                        if (ast.tokencode == 273) {
                            gst = EFindSqlStateType.stsqlplus;
                            (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                            break;
                        }
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (this.gcurrentsqlstatement == null) {
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        if (!this.gcurrentsqlstatement.isnzplsql()) {
                            gst = EFindSqlStateType.stsql;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        gst = EFindSqlStateType.ststoredprocedure;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        foundEnd = false;
                        if (ast.tokencode == 351 || ast.tokencode == 479 || ast.searchToken(479, 4) != null) {
                            waitingEnd = 1;
                            break;
                        }
                        break;
                    }
                }
                case stsqlplus: {
                    if (ast.insqlpluscmd) {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                    gst = EFindSqlStateType.stnormal;
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    break;
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (this.sourcetokenlist.sqlplusaftercurtoken()) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case ststoredprocedure: {
                    if (ast.tokencode == 351) {
                        ++waitingEnd;
                    } else if (ast.tokencode == 305) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 316) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 490) {
                        if (ast.searchToken(313, -1) == null) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 313) {
                        foundEnd = true;
                        if (--waitingEnd < 0) {
                            waitingEnd = 0;
                        }
                    }
                    if (ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (ast.tokentype == ETokenType.ttperiod && this.sourcetokenlist.returnaftercurtoken(false) && this.sourcetokenlist.returnbeforecurtoken(false)) {
                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    if (ast.tokentype == ETokenType.ttsemicolon && waitingEnd == 0 && foundEnd && this.gcurrentsqlstatement.OracleStatementCanBeSeparatedByBeginEndPair()) {
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (ast.searchToken(307, 1) != null && ast.searchToken(477, 4) != null && waitingEnd == 0) {
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    break;
                }
            }
        }
        if (this.gcurrentsqlstatement != null && (gst == EFindSqlStateType.stsqlplus || gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return this.syntaxErrors.size();
    }

    int dooraclegetrawsqlstatements() {
        final int[] waitingEnds = new int[1024];
        final stored_procedure_type[] sptype = new stored_procedure_type[1024];
        final stored_procedure_status[] procedure_status = new stored_procedure_status[1024];
        boolean endBySlashOnly = true;
        int nestedProcedures = 0;
        int nestedParenthesis = 0;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode == 427) {
                final TSourceToken stMatch = ast.searchToken(317, 1);
                if (stMatch != null) {
                    ast.tokencode = 264;
                }
            } else if (ast.tokencode == 548) {
                final TSourceToken stBy = ast.searchToken(340, -1);
                if (stBy != null) {
                    ast.tokencode = 547;
                }
            } else if (ast.tokencode == 549) {
                final TSourceToken stRightParen = ast.searchToken(41, -1);
                if (stRightParen != null) {
                    ast.tokencode = 264;
                }
                TSourceToken stDot = ast.searchToken(46, 1);
                if (stDot != null) {
                    ast.tokencode = 264;
                }
                final TSourceToken stNext = ast.searchTokenAfterObjectName();
                stDot = ast.searchToken(46, 1);
                if (stDot == null && stNext != null && stNext.tokencode == 40) {
                    ast.tokencode = 558;
                }
            } else if (ast.tokencode == 550) {
                final TSourceToken stLeftParen = ast.searchToken(40, 1);
                if (stLeftParen == null) {
                    ast.tokencode = 264;
                }
            } else if (ast.tokencode == 552) {
                final TSourceToken stNext2 = ast.searchToken(551, 1);
                TSourceToken stPrev = ast.searchToken(310, -1);
                if (stPrev == null) {
                    stPrev = ast.searchToken(559, -1);
                }
                if (stNext2 == null && stPrev == null) {
                    ast.tokencode = 264;
                }
            } else if (ast.tokencode == 303) {
                final TSourceToken stPrev2 = ast.searchToken(46, -1);
                if (stPrev2 != null) {
                    ast.tokencode = 264;
                }
            } else if (ast.tokencode == 554) {
                final TSourceToken stPrev2 = ast.searchToken(428, -1);
                if (stPrev2 != null) {
                    stPrev2.tokencode = 553;
                }
            } else if (ast.tokencode == 568) {
                final TSourceToken stPrev2 = ast.searchToken(567, -1);
                if (stPrev2 != null) {
                    ast.tokencode = 569;
                }
            } else if (ast.tokencode == 555) {
                final TSourceToken stPrev2 = ast.searchToken(347, -1);
                if (stPrev2 != null) {
                    stPrev2.tokencode = 281;
                }
            } else if (ast.tokencode == 556) {
                final TSourceToken stNext2 = ast.searchToken("(", 2);
                if (stNext2 != null) {
                    ast.tokencode = 557;
                }
            } else if (ast.tokencode == 513) {
                final TSourceToken stNext2 = ast.searchToken("key", 1);
                if (stNext2 == null) {
                    ast.tokencode = 264;
                }
            } else if (ast.tokencode == 561) {
                TSourceToken stNext2 = ast.searchToken(562, 2);
                if (stNext2 == null) {
                    stNext2 = ast.searchToken(563, 2);
                }
                if (stNext2 != null) {
                    ast.tokencode = 564;
                }
            } else if (ast.tokencode == 531) {
                final TSourceToken stNext2 = ast.searchToken("(", 2);
                if (stNext2 == null) {
                    ast.tokencode = 264;
                }
            } else if (ast.tokencode == 515) {
                final TSourceToken stNext2 = ast.nextSolidToken();
                if (stNext2 == null) {
                    ast.tokencode = 264;
                } else if (stNext2.tokencode != 264) {
                    ast.tokencode = 264;
                }
            } else if (ast.tokencode == 570) {
                final TSourceToken stNext2 = ast.searchToken(571, 1);
                if (stNext2 != null) {
                    ast.tokencode = 572;
                }
            } else if (ast.tokencode == 433) {
                final TSourceToken stNext2 = ast.searchToken(574, 1);
                if (stNext2 == null) {
                    ast.tokencode = 264;
                }
            }
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (this.gcurrentsqlstatement != null) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                        }
                        if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                            ast.tokentype = ETokenType.ttsimplecomment;
                            ast.tokencode = 258;
                            break;
                        }
                        break;
                    } else {
                        if (ast.tokencode == 273) {
                            gst = EFindSqlStateType.stsqlplus;
                            (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                            break;
                        }
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (this.gcurrentsqlstatement == null) {
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        if (!this.gcurrentsqlstatement.isoracleplsql()) {
                            gst = EFindSqlStateType.stsql;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            nestedParenthesis = 0;
                            break;
                        }
                        nestedProcedures = 0;
                        gst = EFindSqlStateType.ststoredprocedure;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        switch (this.gcurrentsqlstatement.sqlstatementtype) {
                            case sstplsql_createprocedure: {
                                sptype[nestedProcedures] = stored_procedure_type.procedure;
                                break;
                            }
                            case sstplsql_createfunction: {
                                sptype[nestedProcedures] = stored_procedure_type.function;
                                break;
                            }
                            case sstplsql_createpackage: {
                                sptype[nestedProcedures] = stored_procedure_type.package_spec;
                                if (ast.searchToken(526, 5) != null) {
                                    sptype[nestedProcedures] = stored_procedure_type.package_body;
                                    break;
                                }
                                break;
                            }
                            case sst_plsql_block: {
                                sptype[nestedProcedures] = stored_procedure_type.block_with_declare;
                                if (ast.tokencode == 351) {
                                    sptype[nestedProcedures] = stored_procedure_type.block_with_begin;
                                    break;
                                }
                                break;
                            }
                            case sstplsql_createtrigger: {
                                sptype[nestedProcedures] = stored_procedure_type.create_trigger;
                                break;
                            }
                            case sstoraclecreatelibrary: {
                                sptype[nestedProcedures] = stored_procedure_type.create_library;
                                break;
                            }
                            case sstplsql_createtype_placeholder: {
                                gst = EFindSqlStateType.stsql;
                                break;
                            }
                            default: {
                                sptype[nestedProcedures] = stored_procedure_type.others;
                                break;
                            }
                        }
                        if (sptype[0] == stored_procedure_type.block_with_declare) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.is_as;
                        } else if (sptype[0] == stored_procedure_type.block_with_begin) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.body;
                        } else if (sptype[0] == stored_procedure_type.procedure) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.start;
                        } else if (sptype[0] == stored_procedure_type.function) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.start;
                        } else if (sptype[0] == stored_procedure_type.package_spec) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.start;
                        } else if (sptype[0] == stored_procedure_type.package_body) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.start;
                        } else if (sptype[0] == stored_procedure_type.create_trigger) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.start;
                        } else if (sptype[0] == stored_procedure_type.create_library) {
                            endBySlashOnly = false;
                            procedure_status[0] = stored_procedure_status.bodyend;
                        } else {
                            endBySlashOnly = true;
                            procedure_status[0] = stored_procedure_status.bodyend;
                        }
                        if (ast.tokencode == 351 || ast.tokencode == 479 || ast.searchToken(479, 4) != null) {
                            waitingEnds[nestedProcedures] = 1;
                            break;
                        }
                        break;
                    }
                }
                case stsqlplus: {
                    if (ast.insqlpluscmd) {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                    gst = EFindSqlStateType.stnormal;
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    break;
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (this.sourcetokenlist.sqlplusaftercurtoken()) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (ast.tokencode == 40) {
                        ++nestedParenthesis;
                    }
                    if (ast.tokencode == 41 && --nestedParenthesis < 0) {
                        nestedParenthesis = 0;
                    }
                    Boolean findNewStmt = false;
                    TCustomSqlStatement lcStmt = null;
                    if (nestedParenthesis == 0 && this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstcreatetable) {
                        lcStmt = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (lcStmt != null) {
                            findNewStmt = true;
                            if (lcStmt.sqlstatementtype == ESqlStatementType.sstselect) {
                                final TSourceToken prevst = ast.prevSolidToken();
                                if (prevst.tokencode == 341 || prevst.tokencode == 40 || prevst.tokencode == 41) {
                                    findNewStmt = false;
                                }
                            }
                        }
                    }
                    if (findNewStmt) {
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        (this.gcurrentsqlstatement = lcStmt).addtokentolist(ast);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case ststoredprocedure: {
                    if (procedure_status[nestedProcedures] != stored_procedure_status.bodyend) {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                    }
                    switch (procedure_status[nestedProcedures]) {
                        case cursor_declare: {
                            if (ast.tokencode == 59 && --nestedProcedures < 0) {
                                nestedProcedures = 0;
                                break;
                            }
                            break;
                        }
                        case start: {
                            if (ast.tokencode == 341 || ast.tokencode == 525) {
                                if (sptype[nestedProcedures] == stored_procedure_type.create_trigger) {
                                    break;
                                }
                                if (sptype[0] == stored_procedure_type.package_spec && nestedProcedures > 0) {
                                    break;
                                }
                                procedure_status[nestedProcedures] = stored_procedure_status.is_as;
                                if (ast.searchToken("language", 1) == null) {
                                    break;
                                }
                                if (nestedProcedures == 0) {
                                    gst = EFindSqlStateType.stsql;
                                    break;
                                }
                                procedure_status[nestedProcedures] = stored_procedure_status.body;
                                --nestedProcedures;
                                break;
                            } else {
                                if (ast.tokencode == 351) {
                                    if (sptype[nestedProcedures] == stored_procedure_type.create_trigger) {
                                        final int[] array = waitingEnds;
                                        final int n = nestedProcedures;
                                        ++array[n];
                                    }
                                    if (nestedProcedures > 0) {
                                        --nestedProcedures;
                                    }
                                    procedure_status[nestedProcedures] = stored_procedure_status.body;
                                    break;
                                }
                                if (ast.tokencode == 313) {
                                    if (nestedProcedures > 0 && waitingEnds[nestedProcedures - 1] == 1 && (sptype[nestedProcedures - 1] == stored_procedure_type.package_body || sptype[nestedProcedures - 1] == stored_procedure_type.package_spec)) {
                                        --nestedProcedures;
                                        procedure_status[nestedProcedures] = stored_procedure_status.bodyend;
                                        break;
                                    }
                                    break;
                                } else if (ast.tokencode == 477 || ast.tokencode == 478) {
                                    if (nestedProcedures > 0 && waitingEnds[nestedProcedures] == 0 && procedure_status[nestedProcedures - 1] == stored_procedure_status.is_as) {
                                        --nestedProcedures;
                                        ++nestedProcedures;
                                        waitingEnds[nestedProcedures] = 0;
                                        procedure_status[nestedProcedures] = stored_procedure_status.start;
                                        break;
                                    }
                                    break;
                                } else if (ast.tokencode == 573) {
                                    if (nestedProcedures > 0 && waitingEnds[nestedProcedures] == 0 && procedure_status[nestedProcedures - 1] == stored_procedure_status.is_as) {
                                        --nestedProcedures;
                                        ++nestedProcedures;
                                        waitingEnds[nestedProcedures] = 0;
                                        procedure_status[nestedProcedures] = stored_procedure_status.cursor_declare;
                                        break;
                                    }
                                    break;
                                } else {
                                    if (sptype[nestedProcedures] == stored_procedure_type.create_trigger && ast.tokencode == 315) {
                                        procedure_status[nestedProcedures] = stored_procedure_status.is_as;
                                        break;
                                    }
                                    if (sptype[nestedProcedures] == stored_procedure_type.create_trigger && ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                                        ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                                        gst = EFindSqlStateType.stnormal;
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        break;
                                    }
                                    if (sptype[nestedProcedures] == stored_procedure_type.create_trigger) {
                                        if (ast.tokencode == 545) {
                                            final TSourceToken compoundSt = ast.searchToken(560, -1);
                                            if (compoundSt != null) {
                                                procedure_status[nestedProcedures] = stored_procedure_status.body;
                                                final int[] array2 = waitingEnds;
                                                final int n2 = nestedProcedures;
                                                ++array2[n2];
                                            }
                                            break;
                                        }
                                        break;
                                    } else {
                                        if (sptype[nestedProcedures] != stored_procedure_type.function || ast.tokencode != 528 || (ast.searchToken("aggregate", -1) == null && ast.searchToken("pipelined", -1) == null)) {
                                            break;
                                        }
                                        if (nestedProcedures == 0) {
                                            gst = EFindSqlStateType.stsql;
                                            break;
                                        }
                                        procedure_status[nestedProcedures] = stored_procedure_status.body;
                                        --nestedProcedures;
                                        break;
                                    }
                                }
                            }
                        }
                        case is_as: {
                            if (ast.tokencode == 477 || ast.tokencode == 478) {
                                ++nestedProcedures;
                                waitingEnds[nestedProcedures] = 0;
                                procedure_status[nestedProcedures] = stored_procedure_status.start;
                                if (nestedProcedures > 1023) {
                                    gst = EFindSqlStateType.sterror;
                                    --nestedProcedures;
                                    break;
                                }
                                break;
                            } else {
                                if (ast.tokencode == 351) {
                                    Label_2787:
                                    {
                                        if (nestedProcedures == 0) {
                                            if (sptype[nestedProcedures] == stored_procedure_type.package_body) {
                                                break Label_2787;
                                            }
                                            if (sptype[nestedProcedures] == stored_procedure_type.package_spec) {
                                                break Label_2787;
                                            }
                                        }
                                        final int[] array3 = waitingEnds;
                                        final int n3 = nestedProcedures;
                                        ++array3[n3];
                                    }
                                    procedure_status[nestedProcedures] = stored_procedure_status.body;
                                    break;
                                }
                                if (ast.tokencode == 313) {
                                    if (nestedProcedures == 0 && waitingEnds[nestedProcedures] == 1 && (sptype[nestedProcedures] == stored_procedure_type.package_body || sptype[nestedProcedures] == stored_procedure_type.package_spec)) {
                                        procedure_status[nestedProcedures] = stored_procedure_status.bodyend;
                                        final int[] array4 = waitingEnds;
                                        final int n4 = nestedProcedures;
                                        --array4[n4];
                                        break;
                                    }
                                    final int[] array5 = waitingEnds;
                                    final int n5 = nestedProcedures;
                                    --array5[n5];
                                    break;
                                } else {
                                    if (ast.tokencode == 316 && ast.searchToken(59, 1) == null) {
                                        final int[] array6 = waitingEnds;
                                        final int n6 = nestedProcedures;
                                        ++array6[n6];
                                        break;
                                    }
                                    break;
                                }
                            }
                        }
                        case body: {
                            if (ast.tokencode == 351) {
                                final int[] array7 = waitingEnds;
                                final int n7 = nestedProcedures;
                                ++array7[n7];
                                break;
                            }
                            if (ast.tokencode == 305) {
                                if (ast.searchToken(59, 2) == null) {
                                    final int[] array8 = waitingEnds;
                                    final int n8 = nestedProcedures;
                                    ++array8[n8];
                                    break;
                                }
                                break;
                            } else if (ast.tokencode == 316) {
                                if (ast.searchToken(59, 2) == null && ast.searchToken(313, -1) == null) {
                                    final int[] array9 = waitingEnds;
                                    final int n9 = nestedProcedures;
                                    ++array9[n9];
                                    break;
                                }
                                break;
                            } else if (ast.tokencode == 490) {
                                if (ast.searchToken(313, -1) == null || ast.searchToken(59, 2) == null) {
                                    final int[] array10 = waitingEnds;
                                    final int n10 = nestedProcedures;
                                    ++array10[n10];
                                    break;
                                }
                                break;
                            } else if (ast.tokencode == 313) {
                                final int[] array11 = waitingEnds;
                                final int n11 = nestedProcedures;
                                --array11[n11];
                                if (waitingEnds[nestedProcedures] != 0) {
                                    break;
                                }
                                if (nestedProcedures == 0) {
                                    procedure_status[nestedProcedures] = stored_procedure_status.bodyend;
                                    break;
                                }
                                --nestedProcedures;
                                procedure_status[nestedProcedures] = stored_procedure_status.is_as;
                                break;
                            } else {
                                if (waitingEnds[nestedProcedures] == 0 && ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                                    ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                                    gst = EFindSqlStateType.stnormal;
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    break;
                                }
                                break;
                            }
                        }
                        case bodyend: {
                            if (ast.tokentype == ETokenType.ttslash && ast.tokencode == 273) {
                                ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.tokentype == ETokenType.ttperiod && this.sourcetokenlist.returnaftercurtoken(false) && this.sourcetokenlist.returnbeforecurtoken(false)) {
                                ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(479, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(477, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(478, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(307, 1) != null && (ast.searchToken(479, 4) != null || ast.searchToken(479, 5) != null) && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(307, 1) != null && (ast.searchToken(477, 4) != null || ast.searchToken(478, 4) != null || ast.searchToken(310, 4) != null || ast.searchToken(575, 4) != null) && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(307, 1) != null && ast.searchToken(546, 4) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(426, 1) != null && ast.searchToken(545, 2) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(301, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(419, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(315, 1) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(423, 1) != null && ast.searchToken(440, 2) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            if (ast.searchToken(426, 1) != null && ast.searchToken(308, 2) != null && !endBySlashOnly) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                    }
                    if (ast.tokencode == 273) {
                        final int m = this.flexer.getkeywordvalue(ast.astext);
                        if (m != 0) {
                            ast.tokencode = m;
                        } else if (ast.tokentype == ETokenType.ttslash) {
                            ast.tokencode = 47;
                        } else {
                            ast.tokencode = 264;
                        }
                    }
                    final int wrapped_keyword_max_pos = 20;
                    if (ast.tokencode != 535 || ast.posinlist - this.gcurrentsqlstatement.sourcetokenlist.get(0).posinlist >= 20) {
                        break;
                    }
                    if (this.gcurrentsqlstatement instanceof TCommonStoredProcedureSqlStatement) {
                        ((TCommonStoredProcedureSqlStatement) this.gcurrentsqlstatement).setWrapped(true);
                    }
                    if (this.gcurrentsqlstatement instanceof TPlsqlCreatePackage && ast.prevSolidToken() != null) {
                        ((TPlsqlCreatePackage) this.gcurrentsqlstatement).setPackageName(this.fparser.getNf().createObjectNameWithPart(ast.prevSolidToken()));
                        break;
                    }
                    break;
                }
            }
        }
        if (this.gcurrentsqlstatement != null && (gst == EFindSqlStateType.stsqlplus || gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return this.syntaxErrors.size();
    }

    int domdxgetrawsqlstatements() {
        int waitingEnd = 0;
        boolean foundEnd = false;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (this.gcurrentsqlstatement != null) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                        }
                        if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                            ast.tokentype = ETokenType.ttsimplecomment;
                            ast.tokencode = 258;
                            break;
                        }
                        break;
                    } else {
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (this.gcurrentsqlstatement == null) {
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmdxscope) {
                            gst = EFindSqlStateType.ststoredprocedure;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            foundEnd = false;
                            waitingEnd = 1;
                            break;
                        }
                        gst = EFindSqlStateType.stsql;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case ststoredprocedure: {
                    if (ast.tokencode == 305) {
                        ++waitingEnd;
                    } else if (ast.tokencode == 316) {
                        ++waitingEnd;
                    } else if (ast.tokencode == 524) {
                        if (lcprevsolidtoken.tokencode != 313) {
                            ++waitingEnd;
                        }
                    } else if (ast.tokencode == 313) {
                        foundEnd = true;
                        if (--waitingEnd < 0) {
                            waitingEnd = 0;
                        }
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    if (ast.tokentype == ETokenType.ttsemicolon && waitingEnd == 0 && foundEnd) {
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    break;
                }
            }
        }
        if (this.gcurrentsqlstatement != null && (gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return this.syntaxErrors.size();
    }

    int doimpalagetrawsqlstatements() {
        return this.dohivegetrawsqlstatements();
    }

    int dohivegetrawsqlstatements() {
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode == 270) {
                final TSourceToken st1 = ast.searchToken(276, 1);
                if (st1 == null) {
                    ast.tokencode = 264;
                }
            } else if (ast.tokencode == 394) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null && st1.tokencode == 40) {
                    ast.tokencode = 541;
                }
            } else if (ast.tokencode == 331) {
                final TSourceToken st1 = ast.searchToken(340, 1);
                if (st1 == null) {
                    ast.tokencode = 264;
                }
            }
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (this.gcurrentsqlstatement != null) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                        }
                        if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                            ast.tokentype = ETokenType.ttsimplecomment;
                            ast.tokencode = 258;
                            break;
                        }
                        break;
                    } else {
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (this.gcurrentsqlstatement != null) {
                            gst = EFindSqlStateType.stsql;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                        ast.tokentype = ETokenType.tttokenlizererrortoken;
                        gst = EFindSqlStateType.sterror;
                        this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                        this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
            }
        }
        if (this.gcurrentsqlstatement != null && (gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return this.syntaxErrors.size();
    }

    int dosybasegetrawsqlstatements() {
        final int errorcount = 0;
        int case_end_nest = 0;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        int lcblocklevel = 0;
        int lctrycatchlevel = 0;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokenstatus == ETokenStatus.tsignoredbygetrawstatement) {
                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
            } else if (gst == EFindSqlStateType.ststoredprocedurebody && ast.tokencode != 463 && ast.tokencode != 307 && ast.tokencode != 426) {
                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
            } else {
                TCustomSqlStatement lcnextsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                switch (gst) {
                    case sterror: {
                        if (TBaseType.assigned(lcnextsqlstatement)) {
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            this.gcurrentsqlstatement = lcnextsqlstatement;
                            this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                            gst = EFindSqlStateType.stsql;
                            break;
                        }
                        if (ast.tokentype == ETokenType.ttsemicolon) {
                            this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            gst = EFindSqlStateType.stnormal;
                            break;
                        }
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        break;
                    }
                    case stnormal: {
                        if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                            if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                            }
                            if (TBaseType.assigned(lcprevsolidtoken) && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                                ast.tokentype = ETokenType.ttsimplecomment;
                                ast.tokencode = 258;
                                break;
                            }
                            break;
                        } else {
                            this.gcurrentsqlstatement = lcnextsqlstatement;
                            if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                                switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                    case sstmssqlcreateprocedure:
                                    case sstmssqlcreatefunction:
                                    case sstcreatetrigger:
                                    case sstmssqlalterprocedure:
                                    case sstmssqlalterfunction:
                                    case sstmssqlaltertrigger: {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        gst = EFindSqlStateType.ststoredprocedure;
                                        break;
                                    }
                                    case sstmssqlbegintry:
                                    case sstmssqlbegincatch: {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        gst = EFindSqlStateType.sttrycatch;
                                        lctrycatchlevel = 0;
                                        break;
                                    }
                                    case sstmssqlgo: {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        gst = EFindSqlStateType.stnormal;
                                        break;
                                    }
                                    default: {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqllabel) {
                                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                            gst = EFindSqlStateType.stnormal;
                                            break;
                                        }
                                        gst = EFindSqlStateType.stsql;
                                        break;
                                    }
                                }
                            } else if (ast.tokencode == 351) {
                                this.gcurrentsqlstatement = new TMssqlBlock(this.dbVendor);
                                this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstmssqlblock;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stblock;
                            } else if (this.sqlstatements.size() == 0) {
                                gst = EFindSqlStateType.stsql;
                                this.gcurrentsqlstatement = new TMssqlExecute(this.dbVendor);
                                ast.tokencode = 566;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                            } else if (this.sqlstatements.get(this.sqlstatements.size() - 1).sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                gst = EFindSqlStateType.stsql;
                                this.gcurrentsqlstatement = new TMssqlExecute(this.dbVendor);
                                ast.tokencode = 566;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                            }
                            if (!TBaseType.assigned(this.gcurrentsqlstatement)) {
                                this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                                ast.tokentype = ETokenType.tttokenlizererrortoken;
                                gst = EFindSqlStateType.sterror;
                                this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                                this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            break;
                        }
                    }
                    case stblock: {
                        if (TBaseType.assigned(lcnextsqlstatement)) {
                            if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                            } else {
                                lcnextsqlstatement = null;
                            }
                        }
                        if (gst != EFindSqlStateType.stblock) {
                            break;
                        }
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokencode == 351) {
                            final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                            if (!TBaseType.assigned(lcnextsolidtoken)) {
                                ++lcblocklevel;
                                break;
                            }
                            if (!TBaseType.mysametext(lcnextsolidtoken.astext, "tran") && !TBaseType.mysametext(lcnextsolidtoken.astext, "transaction") && !TBaseType.mysametext(lcnextsolidtoken.astext, "distributed") && !TBaseType.mysametext(lcnextsolidtoken.astext, "dialog") && !TBaseType.mysametext(lcnextsolidtoken.astext, "conversation")) {
                                ++lcblocklevel;
                                break;
                            }
                            break;
                        } else {
                            if (ast.tokencode == 316) {
                                ++lcblocklevel;
                                break;
                            }
                            if (ast.tokencode != 313) {
                                break;
                            }
                            boolean lcisendconversation = false;
                            final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                            if (TBaseType.assigned(lcnextsolidtoken) && lcnextsolidtoken.tokencode == this.flexer.getkeywordvalue("conversation".toUpperCase())) {
                                lcisendconversation = true;
                            }
                            if (lcisendconversation) {
                                break;
                            }
                            if (lcblocklevel != 0) {
                                --lcblocklevel;
                                break;
                            }
                            if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif && TBaseType.assigned(lcnextsolidtoken)) {
                                if (lcnextsolidtoken.tokencode == 349) {
                                    gst = EFindSqlStateType.stsql;
                                } else if (lcnextsolidtoken.tokentype == ETokenType.ttsemicolon) {
                                    final TSourceToken lcnnextsolidtoken = this.sourcetokenlist.nextsolidtoken(lcnextsolidtoken.posinlist, 1, false);
                                    if (TBaseType.assigned(lcnnextsolidtoken) && lcnnextsolidtoken.tokencode == 349) {
                                        gst = EFindSqlStateType.stsql;
                                    }
                                }
                            }
                            if (gst != EFindSqlStateType.stsql) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                                break;
                            }
                            break;
                        }
                    }
                    case sttrycatch: {
                        if (TBaseType.assigned(lcnextsqlstatement)) {
                            if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                            } else {
                                if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegintry || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegincatch) {
                                    ++lctrycatchlevel;
                                }
                                lcnextsqlstatement = null;
                            }
                        }
                        if (gst != EFindSqlStateType.sttrycatch) {
                            break;
                        }
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if ((ast.tokencode != 456 && ast.tokencode != 462) || !TBaseType.assigned(lcprevsolidtoken) || lcprevsolidtoken.tokencode != 313) {
                            break;
                        }
                        if (lctrycatchlevel == 0) {
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            gst = EFindSqlStateType.stnormal;
                            break;
                        }
                        --lctrycatchlevel;
                        break;
                    }
                    case stsql: {
                        if (ast.tokentype == ETokenType.ttsemicolon) {
                            boolean lcstillinsql = false;
                            if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif) {
                                final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                                if (TBaseType.assigned(lcnextsolidtoken) && lcnextsolidtoken.tokencode == 349) {
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    lcstillinsql = true;
                                }
                            }
                            if (!lcstillinsql) {
                                gst = EFindSqlStateType.stnormal;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                this.gcurrentsqlstatement.semicolonended = ast;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            break;
                        } else if (TBaseType.assigned(lcnextsqlstatement)) {
                            if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                                break;
                            }
                            switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                case sstmssqlif:
                                case sstmssqlwhile: {
                                    if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegincatch || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegintry) {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        gst = EFindSqlStateType.stblock;
                                        lcblocklevel = 1;
                                        lcnextsqlstatement = null;
                                        continue;
                                    }
                                    if (this.gcurrentsqlstatement.dummytag == 1) {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) {
                                            this.gcurrentsqlstatement.dummytag = 1;
                                        } else {
                                            this.gcurrentsqlstatement.dummytag = 0;
                                        }
                                        lcnextsqlstatement = null;
                                        continue;
                                    }
                                    break;
                                }
                                case sstmssqlalterqueue: {
                                    if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlexec) {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        lcnextsqlstatement = null;
                                        continue;
                                    }
                                    break;
                                }
                                case sstmssqlcreateschema: {
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    lcnextsqlstatement = null;
                                    continue;
                                }
                            }
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                            switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                case sstmssqlcreateprocedure:
                                case sstmssqlcreatefunction:
                                case sstcreatetrigger:
                                case sstmssqlalterprocedure:
                                case sstmssqlalterfunction:
                                case sstmssqlaltertrigger: {
                                    gst = EFindSqlStateType.ststoredprocedure;
                                    continue;
                                }
                                case sstmssqlbegintry:
                                case sstmssqlbegincatch: {
                                    gst = EFindSqlStateType.sttrycatch;
                                    lctrycatchlevel = 0;
                                    continue;
                                }
                                case sstmssqlgo: {
                                    gst = EFindSqlStateType.stnormal;
                                    continue;
                                }
                                default: {
                                    gst = EFindSqlStateType.stsql;
                                    continue;
                                }
                            }
                        } else if (ast.tokencode == 351) {
                            if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) {
                                gst = EFindSqlStateType.stblock;
                                lcblocklevel = 0;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqldeclare) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                this.gcurrentsqlstatement = new TMssqlBlock(this.dbVendor);
                                this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstmssqlblock;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stblock;
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        } else {
                            if (ast.tokencode == 316) {
                                ++case_end_nest;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            if (ast.tokencode == 313) {
                                if (case_end_nest > 0) {
                                    --case_end_nest;
                                }
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            if (ast.tokencode == 349) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                if ((this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) && case_end_nest == 0) {
                                    this.gcurrentsqlstatement.dummytag = 1;
                                    break;
                                }
                                break;
                            } else {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlset && ast.tokencode == 323) {
                                    gst = EFindSqlStateType.stnormal;
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    break;
                                }
                                break;
                            }
                        }
                    }
                    case ststoredprocedure: {
                        if (TBaseType.assigned(lcnextsqlstatement)) {
                            if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                            } else {
                                gst = EFindSqlStateType.ststoredprocedurebody;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                lcnextsqlstatement = null;
                            }
                        }
                        if (gst != EFindSqlStateType.ststoredprocedure) {
                            break;
                        }
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokencode == 351) {
                            gst = EFindSqlStateType.stblock;
                            break;
                        }
                        break;
                    }
                    case ststoredprocedurebody: {
                        if (TBaseType.assigned(lcnextsqlstatement)) {
                            switch (lcnextsqlstatement.sqlstatementtype) {
                                case sstmssqlgo: {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    gst = EFindSqlStateType.stnormal;
                                    break;
                                }
                                case sstmssqlcreateprocedure:
                                case sstmssqlcreatefunction:
                                case sstcreatetrigger:
                                case sstmssqlalterprocedure:
                                case sstmssqlalterfunction:
                                case sstmssqlaltertrigger: {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    gst = EFindSqlStateType.ststoredprocedure;
                                    break;
                                }
                                default: {
                                    lcnextsqlstatement = null;
                                    break;
                                }
                            }
                        }
                        if (gst == EFindSqlStateType.ststoredprocedurebody) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        break;
                    }
                }
            }
        }
        if (TBaseType.assigned(this.gcurrentsqlstatement) && gst != EFindSqlStateType.stnormal) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return errorcount;
    }

    int doinformixgetrawsqlstatements() {
        final int errorcount = 0;
        int case_end_nest = 0;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        int lcblocklevel = 0;
        int lctrycatchlevel = 0;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokenstatus == ETokenStatus.tsignoredbygetrawstatement) {
                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
            } else if (gst == EFindSqlStateType.ststoredprocedurebody && ast.tokencode != 463 && ast.tokencode != 307 && ast.tokencode != 426) {
                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
            } else {
                TCustomSqlStatement lcnextsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                switch (gst) {
                    case sterror: {
                        if (TBaseType.assigned(lcnextsqlstatement)) {
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            this.gcurrentsqlstatement = lcnextsqlstatement;
                            this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                            gst = EFindSqlStateType.stsql;
                            break;
                        }
                        if (ast.tokentype == ETokenType.ttsemicolon) {
                            this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            gst = EFindSqlStateType.stnormal;
                            break;
                        }
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        break;
                    }
                    case stnormal: {
                        if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                            if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                            }
                            if (TBaseType.assigned(lcprevsolidtoken) && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                                ast.tokentype = ETokenType.ttsimplecomment;
                                ast.tokencode = 258;
                                break;
                            }
                            break;
                        } else {
                            this.gcurrentsqlstatement = lcnextsqlstatement;
                            if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                                switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                    case sstcreatetrigger:
                                    case sstinformixCreateProcedure:
                                    case sstinformixCreateFunction:
                                    case sstinformixAlterProcedure:
                                    case sstinformixAlterFunction: {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        gst = EFindSqlStateType.ststoredprocedure;
                                        break;
                                    }
                                    case sstmssqlbegintry:
                                    case sstmssqlbegincatch: {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        gst = EFindSqlStateType.sttrycatch;
                                        lctrycatchlevel = 0;
                                        break;
                                    }
                                    case sstmssqlgo: {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        gst = EFindSqlStateType.stnormal;
                                        break;
                                    }
                                    case sstinformixExecute: {
                                        gst = EFindSqlStateType.stExec;
                                        break;
                                    }
                                    default: {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        gst = EFindSqlStateType.stsql;
                                        break;
                                    }
                                }
                            } else if (ast.tokencode == 351) {
                                this.gcurrentsqlstatement = new TMssqlBlock(this.dbVendor);
                                this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstmssqlblock;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stblock;
                            } else if (this.sqlstatements.size() == 0) {
                                gst = EFindSqlStateType.stsql;
                                (this.gcurrentsqlstatement = new TMssqlExecute(this.dbVendor)).addtokentolist(ast);
                            } else if (this.sqlstatements.get(this.sqlstatements.size() - 1).sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                gst = EFindSqlStateType.stsql;
                                (this.gcurrentsqlstatement = new TMssqlExecute(this.dbVendor)).addtokentolist(ast);
                            }
                            if (!TBaseType.assigned(this.gcurrentsqlstatement)) {
                                this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                                ast.tokentype = ETokenType.tttokenlizererrortoken;
                                gst = EFindSqlStateType.sterror;
                                this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                                this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            break;
                        }
                    }
                    case stExec: {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        if (ast.tokentype == ETokenType.ttsemicolon) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        break;
                    }
                    case stblock: {
                        if (TBaseType.assigned(lcnextsqlstatement)) {
                            if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                            } else {
                                lcnextsqlstatement = null;
                            }
                        }
                        if (gst != EFindSqlStateType.stblock) {
                            break;
                        }
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokencode == 351) {
                            final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                            if (!TBaseType.assigned(lcnextsolidtoken)) {
                                ++lcblocklevel;
                                break;
                            }
                            if (!TBaseType.mysametext(lcnextsolidtoken.astext, "tran") && !TBaseType.mysametext(lcnextsolidtoken.astext, "transaction") && !TBaseType.mysametext(lcnextsolidtoken.astext, "distributed") && !TBaseType.mysametext(lcnextsolidtoken.astext, "dialog") && !TBaseType.mysametext(lcnextsolidtoken.astext, "conversation")) {
                                ++lcblocklevel;
                                break;
                            }
                            break;
                        } else {
                            if (ast.tokencode == 316) {
                                ++lcblocklevel;
                                break;
                            }
                            if (ast.tokencode != 313) {
                                break;
                            }
                            boolean lcisendconversation = false;
                            final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                            if (TBaseType.assigned(lcnextsolidtoken) && lcnextsolidtoken.tokencode == this.flexer.getkeywordvalue("conversation".toUpperCase())) {
                                lcisendconversation = true;
                            }
                            if (lcisendconversation) {
                                break;
                            }
                            if (lcblocklevel != 0) {
                                --lcblocklevel;
                                break;
                            }
                            if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif && TBaseType.assigned(lcnextsolidtoken)) {
                                if (lcnextsolidtoken.tokencode == 349) {
                                    gst = EFindSqlStateType.stsql;
                                } else if (lcnextsolidtoken.tokentype == ETokenType.ttsemicolon) {
                                    final TSourceToken lcnnextsolidtoken = this.sourcetokenlist.nextsolidtoken(lcnextsolidtoken.posinlist, 1, false);
                                    if (TBaseType.assigned(lcnnextsolidtoken) && lcnnextsolidtoken.tokencode == 349) {
                                        gst = EFindSqlStateType.stsql;
                                    }
                                }
                            }
                            if (gst != EFindSqlStateType.stsql) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                                break;
                            }
                            break;
                        }
                    }
                    case sttrycatch: {
                        if (TBaseType.assigned(lcnextsqlstatement)) {
                            if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                            } else {
                                if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegintry || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegincatch) {
                                    ++lctrycatchlevel;
                                }
                                lcnextsqlstatement = null;
                            }
                        }
                        if (gst != EFindSqlStateType.sttrycatch) {
                            break;
                        }
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if ((ast.tokencode != 456 && ast.tokencode != 462) || !TBaseType.assigned(lcprevsolidtoken) || lcprevsolidtoken.tokencode != 313) {
                            break;
                        }
                        if (lctrycatchlevel == 0) {
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            gst = EFindSqlStateType.stnormal;
                            break;
                        }
                        --lctrycatchlevel;
                        break;
                    }
                    case stsql: {
                        if (ast.tokentype == ETokenType.ttsemicolon) {
                            boolean lcstillinsql = false;
                            if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif) {
                                final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                                if (TBaseType.assigned(lcnextsolidtoken) && lcnextsolidtoken.tokencode == 349) {
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    lcstillinsql = true;
                                }
                            }
                            if (!lcstillinsql) {
                                gst = EFindSqlStateType.stnormal;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                this.gcurrentsqlstatement.semicolonended = ast;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                            break;
                        } else if (TBaseType.assigned(lcnextsqlstatement)) {
                            if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                                break;
                            }
                            switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                case sstmssqlif:
                                case sstmssqlwhile: {
                                    if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegincatch || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegintry) {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        gst = EFindSqlStateType.stblock;
                                        lcblocklevel = 1;
                                        lcnextsqlstatement = null;
                                        continue;
                                    }
                                    if (this.gcurrentsqlstatement.dummytag == 1) {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) {
                                            this.gcurrentsqlstatement.dummytag = 1;
                                        } else {
                                            this.gcurrentsqlstatement.dummytag = 0;
                                        }
                                        lcnextsqlstatement = null;
                                        continue;
                                    }
                                    break;
                                }
                                case sstmssqlalterqueue: {
                                    if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlexec) {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        lcnextsqlstatement = null;
                                        continue;
                                    }
                                    break;
                                }
                                case sstmssqlcreateschema: {
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    lcnextsqlstatement = null;
                                    continue;
                                }
                            }
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                            switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                case sstcreatetrigger:
                                case sstinformixCreateProcedure:
                                case sstinformixCreateFunction:
                                case sstinformixAlterProcedure:
                                case sstinformixAlterFunction: {
                                    gst = EFindSqlStateType.ststoredprocedure;
                                    continue;
                                }
                                case sstmssqlbegintry:
                                case sstmssqlbegincatch: {
                                    gst = EFindSqlStateType.sttrycatch;
                                    lctrycatchlevel = 0;
                                    continue;
                                }
                                case sstmssqlgo: {
                                    gst = EFindSqlStateType.stnormal;
                                    continue;
                                }
                                default: {
                                    gst = EFindSqlStateType.stsql;
                                    continue;
                                }
                            }
                        } else if (ast.tokencode == 351) {
                            if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) {
                                gst = EFindSqlStateType.stblock;
                                lcblocklevel = 0;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqldeclare) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                this.gcurrentsqlstatement = new TMssqlBlock(this.dbVendor);
                                this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstmssqlblock;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                gst = EFindSqlStateType.stblock;
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        } else {
                            if (ast.tokencode == 316) {
                                ++case_end_nest;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            if (ast.tokencode == 313) {
                                if (case_end_nest > 0) {
                                    --case_end_nest;
                                }
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            if (ast.tokencode != 349) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            if ((this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) && case_end_nest == 0) {
                                this.gcurrentsqlstatement.dummytag = 1;
                                break;
                            }
                            break;
                        }
                    }
                    case ststoredprocedure: {
                        if (TBaseType.assigned(lcnextsqlstatement)) {
                            if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                            } else {
                                gst = EFindSqlStateType.ststoredprocedurebody;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                lcnextsqlstatement = null;
                            }
                        }
                        if (gst != EFindSqlStateType.ststoredprocedure) {
                            break;
                        }
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if ((ast.tokencode == 477 || ast.tokencode == 478) && ast.searchToken(313, -1) != null) {
                            gst = EFindSqlStateType.stsql;
                            break;
                        }
                        break;
                    }
                    case ststoredprocedurebody: {
                        if (TBaseType.assigned(lcnextsqlstatement)) {
                            switch (lcnextsqlstatement.sqlstatementtype) {
                                case sstmssqlgo: {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    gst = EFindSqlStateType.stnormal;
                                    break;
                                }
                                case sstcreatetrigger:
                                case sstinformixCreateProcedure:
                                case sstinformixCreateFunction:
                                case sstinformixAlterProcedure:
                                case sstinformixAlterFunction: {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    gst = EFindSqlStateType.ststoredprocedure;
                                    break;
                                }
                                default: {
                                    lcnextsqlstatement = null;
                                    break;
                                }
                            }
                        }
                        if (gst == EFindSqlStateType.ststoredprocedurebody) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        break;
                    }
                }
            }
        }
        if (TBaseType.assigned(this.gcurrentsqlstatement) && gst != EFindSqlStateType.stnormal) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return errorcount;
    }

    int dosoqlgetrawsqlstatements() {
        final int errorcount = 0;
        int case_end_nest = 0;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        int lcblocklevel = 0;
        int lctrycatchlevel = 0;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        int lcMergeInSelectNested = 0;
        boolean lcMergeInSelect = false;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (lcMergeInSelect) {
                if (ast.tokencode == 40) {
                    ++lcMergeInSelectNested;
                }
                if (ast.tokencode == 41 && --lcMergeInSelectNested == 0) {
                    lcMergeInSelect = false;
                }
                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
            } else if (ast.tokenstatus == ETokenStatus.tsignoredbygetrawstatement) {
                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
            } else {
                if (ast.tokencode == 304) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1 != null && (st1.toString().equalsIgnoreCase("tracking") || st1.toString().equalsIgnoreCase("viewstat"))) {
                        ast.tokencode = 572;
                    }
                }
                if (this.dbVendor == EDbVendor.dbvopenedge) {
                    if (ast.tokencode == 333) {
                        final TSourceToken st1 = ast.searchToken(340, 1);
                        if (st1 == null) {
                            ast.tokencode = 264;
                        }
                    } else if (ast.tokencode == 311) {
                        final TSourceToken st1 = ast.searchToken(499, 1);
                        if (st1 != null) {
                            ast.tokencode = 529;
                        }
                    }
                }
                if (gst == EFindSqlStateType.ststoredprocedurebody && ast.tokencode != 463 && ast.tokencode != 307 && ast.tokencode != 426) {
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                } else {
                    TCustomSqlStatement lcnextsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                    switch (gst) {
                        case sterror: {
                            if (TBaseType.assigned(lcnextsqlstatement)) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                this.gcurrentsqlstatement = lcnextsqlstatement;
                                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                                gst = EFindSqlStateType.stsql;
                                break;
                            }
                            if (ast.tokentype == ETokenType.ttsemicolon) {
                                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                                break;
                            }
                            this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                            break;
                        }
                        case stnormal: {
                            if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                                if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                }
                                if (TBaseType.assigned(lcprevsolidtoken) && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                                    ast.tokentype = ETokenType.ttsimplecomment;
                                    ast.tokencode = 258;
                                    break;
                                }
                                break;
                            } else {
                                this.gcurrentsqlstatement = lcnextsqlstatement;
                                if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                                    switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                        case sstmssqlcreateprocedure:
                                        case sstmssqlcreatefunction:
                                        case sstcreatetrigger:
                                        case sstmssqlalterprocedure:
                                        case sstmssqlalterfunction:
                                        case sstmssqlaltertrigger: {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            gst = EFindSqlStateType.ststoredprocedure;
                                            break;
                                        }
                                        case sstmssqlbegintry:
                                        case sstmssqlbegincatch: {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            gst = EFindSqlStateType.sttrycatch;
                                            lctrycatchlevel = 0;
                                            break;
                                        }
                                        case sstmssqlgo: {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                            gst = EFindSqlStateType.stnormal;
                                            break;
                                        }
                                        default: {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            gst = EFindSqlStateType.stsql;
                                            break;
                                        }
                                    }
                                } else if (ast.tokencode == 351) {
                                    this.gcurrentsqlstatement = new TMssqlBlock(this.dbVendor);
                                    this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstmssqlblock;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    gst = EFindSqlStateType.stblock;
                                } else if (this.sqlstatements.size() == 0) {
                                    gst = EFindSqlStateType.stsql;
                                    (this.gcurrentsqlstatement = new TMssqlExecute(this.dbVendor)).addtokentolist(ast);
                                } else if (this.sqlstatements.get(this.sqlstatements.size() - 1).sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                    gst = EFindSqlStateType.stsql;
                                    (this.gcurrentsqlstatement = new TMssqlExecute(this.dbVendor)).addtokentolist(ast);
                                }
                                if (!TBaseType.assigned(this.gcurrentsqlstatement)) {
                                    this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                                    ast.tokentype = ETokenType.tttokenlizererrortoken;
                                    gst = EFindSqlStateType.sterror;
                                    this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                                    this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                break;
                            }
                        }
                        case stblock: {
                            if (TBaseType.assigned(lcnextsqlstatement)) {
                                if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    gst = EFindSqlStateType.stnormal;
                                } else {
                                    lcnextsqlstatement = null;
                                }
                            }
                            if (gst != EFindSqlStateType.stblock) {
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            if (ast.tokencode == 351) {
                                final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                                if (!TBaseType.assigned(lcnextsolidtoken)) {
                                    ++lcblocklevel;
                                    break;
                                }
                                if (!TBaseType.mysametext(lcnextsolidtoken.astext, "tran") && !TBaseType.mysametext(lcnextsolidtoken.astext, "transaction") && !TBaseType.mysametext(lcnextsolidtoken.astext, "distributed") && !TBaseType.mysametext(lcnextsolidtoken.astext, "dialog") && !TBaseType.mysametext(lcnextsolidtoken.astext, "conversation")) {
                                    ++lcblocklevel;
                                    break;
                                }
                                break;
                            } else {
                                if (ast.tokencode == 316) {
                                    ++lcblocklevel;
                                    break;
                                }
                                if (ast.tokencode != 313) {
                                    break;
                                }
                                boolean lcisendconversation = false;
                                final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                                if (TBaseType.assigned(lcnextsolidtoken) && lcnextsolidtoken.tokencode == this.flexer.getkeywordvalue("conversation".toUpperCase())) {
                                    lcisendconversation = true;
                                }
                                if (lcisendconversation) {
                                    break;
                                }
                                if (lcblocklevel != 0) {
                                    --lcblocklevel;
                                    break;
                                }
                                if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif && TBaseType.assigned(lcnextsolidtoken)) {
                                    if (lcnextsolidtoken.tokencode == 349) {
                                        gst = EFindSqlStateType.stsql;
                                    } else if (lcnextsolidtoken.tokentype == ETokenType.ttsemicolon) {
                                        final TSourceToken lcnnextsolidtoken = this.sourcetokenlist.nextsolidtoken(lcnextsolidtoken.posinlist, 1, false);
                                        if (TBaseType.assigned(lcnnextsolidtoken) && lcnnextsolidtoken.tokencode == 349) {
                                            gst = EFindSqlStateType.stsql;
                                        }
                                    }
                                }
                                if (gst != EFindSqlStateType.stsql) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    gst = EFindSqlStateType.stnormal;
                                    break;
                                }
                                break;
                            }
                        }
                        case sttrycatch: {
                            if (TBaseType.assigned(lcnextsqlstatement)) {
                                if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    gst = EFindSqlStateType.stnormal;
                                } else {
                                    if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegintry || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegincatch) {
                                        ++lctrycatchlevel;
                                    }
                                    lcnextsqlstatement = null;
                                }
                            }
                            if (gst != EFindSqlStateType.sttrycatch) {
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            if ((ast.tokencode != 456 && ast.tokencode != 462) || !TBaseType.assigned(lcprevsolidtoken) || lcprevsolidtoken.tokencode != 313) {
                                break;
                            }
                            if (lctrycatchlevel == 0) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                                break;
                            }
                            --lctrycatchlevel;
                            break;
                        }
                        case stsql: {
                            if (ast.tokentype == ETokenType.ttsemicolon) {
                                boolean lcstillinsql = false;
                                if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif) {
                                    final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                                    if (TBaseType.assigned(lcnextsolidtoken) && lcnextsolidtoken.tokencode == 349) {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        lcstillinsql = true;
                                    }
                                }
                                if (!lcstillinsql) {
                                    gst = EFindSqlStateType.stnormal;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    this.gcurrentsqlstatement.semicolonended = ast;
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    break;
                                }
                                break;
                            } else if (TBaseType.assigned(lcnextsqlstatement)) {
                                if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    gst = EFindSqlStateType.stnormal;
                                    break;
                                }
                                switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                    case sstmssqlif:
                                    case sstmssqlwhile: {
                                        if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegincatch || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegintry) {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            gst = EFindSqlStateType.stblock;
                                            lcblocklevel = 1;
                                            lcnextsqlstatement = null;
                                            continue;
                                        }
                                        if (this.gcurrentsqlstatement.dummytag == 1) {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) {
                                                this.gcurrentsqlstatement.dummytag = 1;
                                            } else {
                                                this.gcurrentsqlstatement.dummytag = 0;
                                            }
                                            lcnextsqlstatement = null;
                                            continue;
                                        }
                                        break;
                                    }
                                    case sstmssqlalterqueue: {
                                        if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlexec) {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            lcnextsqlstatement = null;
                                            continue;
                                        }
                                        break;
                                    }
                                    case sstmssqlcreateschema: {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        lcnextsqlstatement = null;
                                        continue;
                                    }
                                }
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                    case sstmssqlcreateprocedure:
                                    case sstmssqlcreatefunction:
                                    case sstcreatetrigger:
                                    case sstmssqlalterprocedure:
                                    case sstmssqlalterfunction:
                                    case sstmssqlaltertrigger: {
                                        gst = EFindSqlStateType.ststoredprocedure;
                                        continue;
                                    }
                                    case sstmssqlbegintry:
                                    case sstmssqlbegincatch: {
                                        gst = EFindSqlStateType.sttrycatch;
                                        lctrycatchlevel = 0;
                                        continue;
                                    }
                                    case sstmssqlgo: {
                                        gst = EFindSqlStateType.stnormal;
                                        continue;
                                    }
                                    default: {
                                        gst = EFindSqlStateType.stsql;
                                        continue;
                                    }
                                }
                            } else if (ast.tokencode == 351) {
                                if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) {
                                    gst = EFindSqlStateType.stblock;
                                    lcblocklevel = 0;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqldeclare) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    this.gcurrentsqlstatement = new TMssqlBlock(this.dbVendor);
                                    this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstmssqlblock;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    gst = EFindSqlStateType.stblock;
                                    break;
                                }
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            } else {
                                if (ast.tokencode == 316) {
                                    ++case_end_nest;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                if (ast.tokencode == 313) {
                                    if (case_end_nest > 0) {
                                        --case_end_nest;
                                    }
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                if (ast.tokencode != 349) {
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                if ((this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) && case_end_nest == 0) {
                                    this.gcurrentsqlstatement.dummytag = 1;
                                    break;
                                }
                                break;
                            }
                        }
                        case ststoredprocedure: {
                            if (TBaseType.assigned(lcnextsqlstatement)) {
                                if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    gst = EFindSqlStateType.stnormal;
                                } else {
                                    gst = EFindSqlStateType.ststoredprocedurebody;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    lcnextsqlstatement = null;
                                }
                            }
                            if (gst != EFindSqlStateType.ststoredprocedure) {
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            if (ast.tokencode == 351) {
                                gst = EFindSqlStateType.stblock;
                                break;
                            }
                            break;
                        }
                        case ststoredprocedurebody: {
                            if (TBaseType.assigned(lcnextsqlstatement)) {
                                switch (lcnextsqlstatement.sqlstatementtype) {
                                    case sstmssqlgo: {
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        gst = EFindSqlStateType.stnormal;
                                        break;
                                    }
                                    case sstmssqlcreateprocedure:
                                    case sstmssqlcreatefunction:
                                    case sstcreatetrigger:
                                    case sstmssqlalterprocedure:
                                    case sstmssqlalterfunction:
                                    case sstmssqlaltertrigger: {
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                        gst = EFindSqlStateType.ststoredprocedure;
                                        break;
                                    }
                                    case sstcreateview:
                                    case sstcreatetable: {
                                        boolean readForNewStmt = false;
                                        final TSourceToken st2 = ast.searchToken(59, -1);
                                        if (st2 != null) {
                                            final TSourceToken st3 = ast.searchToken(313, -2);
                                            if (st3 != null) {
                                                readForNewStmt = true;
                                            }
                                        }
                                        if (readForNewStmt) {
                                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                            (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                            gst = EFindSqlStateType.stsql;
                                            break;
                                        }
                                        lcnextsqlstatement = null;
                                        break;
                                    }
                                    default: {
                                        lcnextsqlstatement = null;
                                        break;
                                    }
                                }
                            }
                            if (gst == EFindSqlStateType.ststoredprocedurebody) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            break;
                        }
                    }
                }
            }
        }
        if (TBaseType.assigned(this.gcurrentsqlstatement) && gst != EFindSqlStateType.stnormal) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return errorcount;
    }

    int domssqlgetrawsqlstatements() {
        final int errorcount = 0;
        int case_end_nest = 0;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        int lcblocklevel = 0;
        int lctrycatchlevel = 0;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        int lcMergeInSelectNested = 0;
        boolean lcMergeInSelect = false;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode == 306) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null && st1.tokencode == 564) {
                    ast.tokencode = 285;
                }
            }
            if (lcMergeInSelect) {
                if (ast.tokencode == 40) {
                    ++lcMergeInSelectNested;
                }
                if (ast.tokencode == 41 && --lcMergeInSelectNested == 0) {
                    lcMergeInSelect = false;
                }
                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
            } else if (ast.tokenstatus == ETokenStatus.tsignoredbygetrawstatement) {
                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
            } else {
                if (ast.tokencode == 353) {
                    TSourceToken st1 = ast.searchToken(40, 1);
                    if (st1 == null) {
                        st1 = ast.searchToken(301, 1);
                        if (st1 == null) {
                            ast.tokencode = 264;
                        }
                    }
                } else if (ast.tokencode == 418) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1.tokencode == 324) {
                        ast.tokencode = 287;
                    }
                    if (lcprevsolidtoken != null && lcprevsolidtoken.tokencode == 40) {
                        lcMergeInSelect = true;
                        ++lcMergeInSelectNested;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        continue;
                    }
                } else if (ast.tokencode == 558) {
                    if (lcprevsolidtoken != null && lcprevsolidtoken.tokencode == 46) {
                        final TSourceToken st1 = ast.searchToken(40, 1);
                        if (st1 != null) {
                            ast.tokencode = 553;
                        }
                    }
                } else if (ast.tokencode == 559) {
                    if (lcprevsolidtoken != null && lcprevsolidtoken.tokencode == 46) {
                        final TSourceToken st1 = ast.searchToken(40, 1);
                        if (st1 != null) {
                            ast.tokencode = 554;
                        }
                    }
                } else if (ast.tokencode == 560) {
                    if (lcprevsolidtoken != null && lcprevsolidtoken.tokencode == 46) {
                        final TSourceToken st1 = ast.searchToken(40, 1);
                        if (st1 != null) {
                            ast.tokencode = 555;
                        }
                    }
                } else if (ast.tokencode == 561) {
                    if (lcprevsolidtoken != null && lcprevsolidtoken.tokencode == 46) {
                        final TSourceToken st1 = ast.searchToken(40, 1);
                        if (st1 != null) {
                            ast.tokencode = 556;
                        }
                    }
                } else if (ast.tokencode == 562) {
                    if (lcprevsolidtoken != null && lcprevsolidtoken.tokencode == 46) {
                        final TSourceToken st1 = ast.searchToken(40, 1);
                        if (st1 != null) {
                            ast.tokencode = 557;
                        }
                    }
                } else if (ast.tokencode == 499) {
                    if (lcprevsolidtoken != null && lcprevsolidtoken.tokencode == 311) {
                        lcprevsolidtoken.tokencode = 576;
                    }
                } else if (ast.tokencode == 566) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1 != null && st1.tokencode == 46) {
                        ast.tokencode = 264;
                    }
                } else if (ast.tokencode == 334) {
                    if (lcprevsolidtoken != null && (lcprevsolidtoken.tokencode == 567 || lcprevsolidtoken.tokencode == 568)) {
                        final TSourceToken prev2 = lcprevsolidtoken.searchToken(443, -1);
                        if (prev2 == null) {
                            ast.tokencode = 569;
                        }
                    }
                } else if (ast.tokencode == 439 || ast.tokencode == 440) {
                    final TSourceToken st1 = ast.searchToken(59, 4);
                    if (st1 != null) {
                        final TSourceToken numSt = st1.nextSolidToken();
                        if (numSt != null && numSt.tokentype == ETokenType.ttnumber) {
                            st1.tokencode = 577;
                        }
                    }
                }
                if (this.dbVendor == EDbVendor.dbvopenedge) {
                    if (ast.tokencode == 333) {
                        final TSourceToken st1 = ast.searchToken(340, 1);
                        if (st1 == null) {
                            ast.tokencode = 264;
                        }
                    } else if (ast.tokencode == 311) {
                        final TSourceToken st1 = ast.searchToken(499, 1);
                        if (st1 != null) {
                            ast.tokencode = 529;
                        }
                    }
                }
                if (gst == EFindSqlStateType.ststoredprocedurebody && ast.tokencode != 463 && ast.tokencode != 307 && ast.tokencode != 426) {
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                } else {
                    TCustomSqlStatement lcnextsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                    switch (gst) {
                        case sterror: {
                            if (TBaseType.assigned(lcnextsqlstatement)) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                this.gcurrentsqlstatement = lcnextsqlstatement;
                                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                                gst = EFindSqlStateType.stsql;
                                break;
                            }
                            if (ast.tokentype == ETokenType.ttsemicolon) {
                                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                                break;
                            }
                            this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                            break;
                        }
                        case stnormal: {
                            if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                                if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                }
                                if (TBaseType.assigned(lcprevsolidtoken) && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                                    ast.tokentype = ETokenType.ttsimplecomment;
                                    ast.tokencode = 258;
                                    break;
                                }
                                break;
                            } else {
                                this.gcurrentsqlstatement = lcnextsqlstatement;
                                if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                                    switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                        case sstmssqlcreateprocedure:
                                        case sstmssqlcreatefunction:
                                        case sstcreatetrigger:
                                        case sstmssqlalterprocedure:
                                        case sstmssqlalterfunction:
                                        case sstmssqlaltertrigger: {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            gst = EFindSqlStateType.ststoredprocedure;
                                            break;
                                        }
                                        case sstmssqlbegintry:
                                        case sstmssqlbegincatch: {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            gst = EFindSqlStateType.sttrycatch;
                                            lctrycatchlevel = 0;
                                            break;
                                        }
                                        case sstmssqlgo: {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                            gst = EFindSqlStateType.stnormal;
                                            break;
                                        }
                                        default: {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            gst = EFindSqlStateType.stsql;
                                            break;
                                        }
                                    }
                                } else if (ast.tokencode == 351) {
                                    this.gcurrentsqlstatement = new TMssqlBlock(this.dbVendor);
                                    this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstmssqlblock;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    gst = EFindSqlStateType.stblock;
                                } else if (this.sqlstatements.size() == 0) {
                                    gst = EFindSqlStateType.stsql;
                                    (this.gcurrentsqlstatement = new TMssqlExecute(this.dbVendor)).addtokentolist(ast);
                                } else if (this.sqlstatements.get(this.sqlstatements.size() - 1).sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                    gst = EFindSqlStateType.stsql;
                                    (this.gcurrentsqlstatement = new TMssqlExecute(this.dbVendor)).addtokentolist(ast);
                                }
                                if (!TBaseType.assigned(this.gcurrentsqlstatement)) {
                                    this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                                    ast.tokentype = ETokenType.tttokenlizererrortoken;
                                    gst = EFindSqlStateType.sterror;
                                    this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                                    this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                break;
                            }
                        }
                        case stblock: {
                            if (TBaseType.assigned(lcnextsqlstatement)) {
                                if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    gst = EFindSqlStateType.stnormal;
                                } else {
                                    lcnextsqlstatement = null;
                                }
                            }
                            if (gst != EFindSqlStateType.stblock) {
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            if (ast.tokencode == 351) {
                                final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                                if (!TBaseType.assigned(lcnextsolidtoken)) {
                                    ++lcblocklevel;
                                    break;
                                }
                                if (!TBaseType.mysametext(lcnextsolidtoken.astext, "tran") && !TBaseType.mysametext(lcnextsolidtoken.astext, "transaction") && !TBaseType.mysametext(lcnextsolidtoken.astext, "distributed") && !TBaseType.mysametext(lcnextsolidtoken.astext, "dialog") && !TBaseType.mysametext(lcnextsolidtoken.astext, "conversation")) {
                                    ++lcblocklevel;
                                    break;
                                }
                                break;
                            } else {
                                if (ast.tokencode == 316) {
                                    ++lcblocklevel;
                                    break;
                                }
                                if (ast.tokencode != 313) {
                                    break;
                                }
                                boolean lcisendconversation = false;
                                final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                                if (TBaseType.assigned(lcnextsolidtoken) && lcnextsolidtoken.tokencode == this.flexer.getkeywordvalue("conversation".toUpperCase())) {
                                    lcisendconversation = true;
                                }
                                if (lcisendconversation) {
                                    break;
                                }
                                if (lcblocklevel != 0) {
                                    --lcblocklevel;
                                    break;
                                }
                                if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif && TBaseType.assigned(lcnextsolidtoken)) {
                                    if (lcnextsolidtoken.tokencode == 349) {
                                        gst = EFindSqlStateType.stsql;
                                    } else if (lcnextsolidtoken.tokentype == ETokenType.ttsemicolon) {
                                        final TSourceToken lcnnextsolidtoken = this.sourcetokenlist.nextsolidtoken(lcnextsolidtoken.posinlist, 1, false);
                                        if (TBaseType.assigned(lcnnextsolidtoken) && lcnnextsolidtoken.tokencode == 349) {
                                            gst = EFindSqlStateType.stsql;
                                        }
                                    }
                                }
                                if (gst != EFindSqlStateType.stsql) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    gst = EFindSqlStateType.stnormal;
                                    break;
                                }
                                break;
                            }
                        }
                        case sttrycatch: {
                            if (TBaseType.assigned(lcnextsqlstatement)) {
                                if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    gst = EFindSqlStateType.stnormal;
                                } else {
                                    if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegintry || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegincatch) {
                                        ++lctrycatchlevel;
                                    }
                                    lcnextsqlstatement = null;
                                }
                            }
                            if (gst != EFindSqlStateType.sttrycatch) {
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            if ((ast.tokencode != 456 && ast.tokencode != 462) || !TBaseType.assigned(lcprevsolidtoken) || lcprevsolidtoken.tokencode != 313) {
                                break;
                            }
                            if (lctrycatchlevel == 0) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                                break;
                            }
                            --lctrycatchlevel;
                            break;
                        }
                        case stsql: {
                            if (ast.tokentype == ETokenType.ttsemicolon) {
                                boolean lcstillinsql = false;
                                if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif) {
                                    final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                                    if (TBaseType.assigned(lcnextsolidtoken) && lcnextsolidtoken.tokencode == 349) {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        lcstillinsql = true;
                                    }
                                }
                                if (!lcstillinsql) {
                                    gst = EFindSqlStateType.stnormal;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    this.gcurrentsqlstatement.semicolonended = ast;
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    break;
                                }
                                break;
                            } else if (TBaseType.assigned(lcnextsqlstatement)) {
                                if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    gst = EFindSqlStateType.stnormal;
                                    break;
                                }
                                switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                    case sstmssqlif:
                                    case sstmssqlwhile: {
                                        if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegincatch || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlbegintry) {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            gst = EFindSqlStateType.stblock;
                                            lcblocklevel = 1;
                                            lcnextsqlstatement = null;
                                            continue;
                                        }
                                        if (this.gcurrentsqlstatement.dummytag == 1) {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) {
                                                this.gcurrentsqlstatement.dummytag = 1;
                                            } else {
                                                this.gcurrentsqlstatement.dummytag = 0;
                                            }
                                            lcnextsqlstatement = null;
                                            continue;
                                        }
                                        break;
                                    }
                                    case sstmssqlalterqueue: {
                                        if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlexec) {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            lcnextsqlstatement = null;
                                            continue;
                                        }
                                        break;
                                    }
                                    case sstmssqlcreateschema: {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        lcnextsqlstatement = null;
                                        continue;
                                    }
                                }
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                    case sstmssqlcreateprocedure:
                                    case sstmssqlcreatefunction:
                                    case sstcreatetrigger:
                                    case sstmssqlalterprocedure:
                                    case sstmssqlalterfunction:
                                    case sstmssqlaltertrigger: {
                                        gst = EFindSqlStateType.ststoredprocedure;
                                        continue;
                                    }
                                    case sstmssqlbegintry:
                                    case sstmssqlbegincatch: {
                                        gst = EFindSqlStateType.sttrycatch;
                                        lctrycatchlevel = 0;
                                        continue;
                                    }
                                    case sstmssqlgo: {
                                        gst = EFindSqlStateType.stnormal;
                                        continue;
                                    }
                                    default: {
                                        gst = EFindSqlStateType.stsql;
                                        continue;
                                    }
                                }
                            } else if (ast.tokencode == 351) {
                                if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) {
                                    gst = EFindSqlStateType.stblock;
                                    lcblocklevel = 0;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqldeclare) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    this.gcurrentsqlstatement = new TMssqlBlock(this.dbVendor);
                                    this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstmssqlblock;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    gst = EFindSqlStateType.stblock;
                                    break;
                                }
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            } else {
                                if (ast.tokencode == 316) {
                                    ++case_end_nest;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                if (ast.tokencode == 313) {
                                    if (case_end_nest > 0) {
                                        --case_end_nest;
                                    }
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                if (ast.tokencode != 349) {
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                if ((this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) && case_end_nest == 0) {
                                    this.gcurrentsqlstatement.dummytag = 1;
                                    break;
                                }
                                break;
                            }
                        }
                        case ststoredprocedure: {
                            if (TBaseType.assigned(lcnextsqlstatement)) {
                                if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    gst = EFindSqlStateType.stnormal;
                                } else {
                                    gst = EFindSqlStateType.ststoredprocedurebody;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    lcnextsqlstatement = null;
                                }
                            }
                            if (gst != EFindSqlStateType.ststoredprocedure) {
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            if (ast.tokencode == 351) {
                                gst = EFindSqlStateType.stblock;
                                break;
                            }
                            break;
                        }
                        case ststoredprocedurebody: {
                            if (TBaseType.assigned(lcnextsqlstatement)) {
                                switch (lcnextsqlstatement.sqlstatementtype) {
                                    case sstmssqlgo: {
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        gst = EFindSqlStateType.stnormal;
                                        break;
                                    }
                                    case sstmssqlcreateprocedure:
                                    case sstmssqlcreatefunction:
                                    case sstcreatetrigger:
                                    case sstmssqlalterprocedure:
                                    case sstmssqlalterfunction:
                                    case sstmssqlaltertrigger: {
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                        gst = EFindSqlStateType.ststoredprocedure;
                                        break;
                                    }
                                    case sstcreateview:
                                    case sstcreatetable: {
                                        boolean readForNewStmt = false;
                                        final TSourceToken st2 = ast.searchToken(59, -1);
                                        if (st2 != null) {
                                            final TSourceToken st3 = ast.searchToken(313, -2);
                                            if (st3 != null) {
                                                readForNewStmt = true;
                                            }
                                        }
                                        if (readForNewStmt) {
                                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                            (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                            gst = EFindSqlStateType.stsql;
                                            break;
                                        }
                                        lcnextsqlstatement = null;
                                        break;
                                    }
                                    default: {
                                        lcnextsqlstatement = null;
                                        break;
                                    }
                                }
                            }
                            if (gst == EFindSqlStateType.ststoredprocedurebody) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            break;
                        }
                    }
                }
            }
        }
        if (TBaseType.assigned(this.gcurrentsqlstatement) && gst != EFindSqlStateType.stnormal) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return errorcount;
    }

    private TCustomSqlStatement startDaxStmt(final TSourceToken currToken, final TCustomSqlStatement currStmt) {
        TCustomSqlStatement newStmt = null;
        if (currToken == null) {
            return null;
        }
        if (currToken.tokencode == 61 && currToken.isFirstTokenOfLine()) {
            currToken.tokencode = 276;
            newStmt = new TDaxExprStmt(EDbVendor.dbvdax);
        } else if (currToken.tokencode == 529 && currToken.isFirstTokenOfLine()) {
            newStmt = new TDaxEvaluateStmt(EDbVendor.dbvdax);
            ((TDaxEvaluateStmt) newStmt).setStartWithDefine(true);
        } else if (currToken.tokencode == 530 && currToken.isFirstTokenOfLine()) {
            if (currStmt != null && currStmt instanceof TDaxEvaluateStmt) {
                final TDaxEvaluateStmt tmp = (TDaxEvaluateStmt) currStmt;
                if (tmp.isStartWithDefine()) {
                    return null;
                }
            }
            newStmt = new TDaxEvaluateStmt(EDbVendor.dbvdax);
        }
        if (newStmt == null) {
            final boolean isFirst = currToken.isFirstTokenOfLine();
            final TSourceToken prevToken = currToken.prevSolidToken();
            if (isFirst && prevToken == null) {
                newStmt = new TDaxExprStmt(EDbVendor.dbvdax);
            }
        }
        return newStmt;
    }

    int doodbcgetrawsqlstatements() {
        return this.domssqlgetrawsqlstatements();
    }

    int dodaxgetrawsqlstatements() {
        this.gcurrentsqlstatement = null;
        TCustomSqlStatement tmpStmt = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        final int errorcount = 0;
        int nestedParens = 0;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            final TSourceToken ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode == 531 || ast.tokencode == 532 || ast.tokencode == 533 || ast.tokencode == 534 || ast.tokencode == 535) {
                final TSourceToken st1 = ast.searchToken("(", 1);
                if (st1 == null) {
                    ast.tokencode = 264;
                }
            }
            if (ast.tokencode == 40) {
                ++nestedParens;
            }
            if (ast.tokencode == 41) {
                --nestedParens;
            }
            if (nestedParens > 0) {
                if (this.gcurrentsqlstatement != null) {
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                }
            } else {
                switch (gst) {
                    case sterror: {
                        tmpStmt = this.startDaxStmt(ast, this.gcurrentsqlstatement);
                        if (tmpStmt != null) {
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            this.gcurrentsqlstatement = tmpStmt;
                            this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                            gst = EFindSqlStateType.stsql;
                            break;
                        }
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        break;
                    }
                    case stnormal: {
                        if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                            if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            break;
                        } else {
                            this.gcurrentsqlstatement = this.startDaxStmt(ast, this.gcurrentsqlstatement);
                            if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                                gst = EFindSqlStateType.stsql;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                    }
                    case stsql: {
                        tmpStmt = this.startDaxStmt(ast, this.gcurrentsqlstatement);
                        if (tmpStmt != null) {
                            gst = EFindSqlStateType.stsql;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            (this.gcurrentsqlstatement = tmpStmt).addtokentolist(ast);
                            break;
                        }
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                }
            }
        }
        if (TBaseType.assigned(this.gcurrentsqlstatement) && (gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return errorcount;
    }

    int dohanagetrawsqlstatements() {
        final int errorcount = 0;
        int case_end_nest = 0;
        if (TBaseType.assigned(this.sqlstatements)) {
            this.sqlstatements.clear();
        }
        if (!TBaseType.assigned(this.sourcetokenlist)) {
            return -1;
        }
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        int lcblocklevel = 0;
        final int lctrycatchlevel = 0;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        int lcMergeInSelectNested = 0;
        boolean lcMergeInSelect = false;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (lcMergeInSelect) {
                if (ast.tokencode == 40) {
                    ++lcMergeInSelectNested;
                }
                if (ast.tokencode == 41 && --lcMergeInSelectNested == 0) {
                    lcMergeInSelect = false;
                }
                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
            } else if (ast.tokenstatus == ETokenStatus.tsignoredbygetrawstatement) {
                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
            } else {
                if (ast.tokencode == 353) {
                    TSourceToken st1 = ast.searchToken(40, 1);
                    if (st1 == null) {
                        st1 = ast.searchToken(301, 1);
                        if (st1 == null) {
                            ast.tokencode = 264;
                        }
                    }
                } else if (ast.tokencode == 418) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1.tokencode == 324) {
                        ast.tokencode = 287;
                    }
                    if (lcprevsolidtoken != null && lcprevsolidtoken.tokencode == 40) {
                        lcMergeInSelect = true;
                        ++lcMergeInSelectNested;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        continue;
                    }
                } else if (ast.tokencode == 341) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1.tokencode == 534) {
                        ast.tokencode = 531;
                    }
                } else if (ast.tokencode == 394) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1.tokencode == 262) {
                        ast.tokencode = 535;
                    }
                } else if (ast.tokencode == 393) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1.tokencode == 262) {
                        ast.tokencode = 536;
                    }
                } else if (ast.tokencode == 395) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1.tokencode == 262) {
                        ast.tokencode = 537;
                    }
                } else if (ast.tokencode == 311) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1.toString().equalsIgnoreCase("structured")) {
                        ast.tokencode = 538;
                    } else if (st1.toString().equalsIgnoreCase("cache")) {
                        ast.tokencode = 539;
                    } else if (st1.toString().equalsIgnoreCase("static")) {
                        ast.tokencode = 539;
                    } else if (st1.toString().equalsIgnoreCase("dynamic")) {
                        ast.tokencode = 539;
                    } else if (st1.toString().equalsIgnoreCase("check")) {
                        ast.tokencode = 540;
                    } else if (st1.toString().equalsIgnoreCase("mask")) {
                        ast.tokencode = 546;
                    } else if (st1.toString().equalsIgnoreCase("expression")) {
                        ast.tokencode = 547;
                    }
                } else if (ast.tokencode == 542) {
                    final TSourceToken st1 = ast.nextSolidToken();
                    if (st1.toString().equalsIgnoreCase("priority")) {
                        ast.tokencode = 543;
                    }
                }
                if (gst == EFindSqlStateType.ststoredprocedurebody && ast.tokencode != 463 && ast.tokencode != 307 && ast.tokencode != 426) {
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                } else {
                    TCustomSqlStatement lcnextsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                    switch (gst) {
                        case sterror: {
                            if (TBaseType.assigned(lcnextsqlstatement)) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                this.gcurrentsqlstatement = lcnextsqlstatement;
                                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                                gst = EFindSqlStateType.stsql;
                                break;
                            }
                            if (ast.tokentype == ETokenType.ttsemicolon) {
                                this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                                break;
                            }
                            this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                            break;
                        }
                        case stnormal: {
                            if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                                if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                }
                                if (TBaseType.assigned(lcprevsolidtoken) && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                                    ast.tokentype = ETokenType.ttsimplecomment;
                                    ast.tokencode = 258;
                                    break;
                                }
                                break;
                            } else {
                                this.gcurrentsqlstatement = lcnextsqlstatement;
                                if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                                    switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                        case sstcreateprocedure:
                                        case sstcreatetrigger:
                                        case sstcreatefunction:
                                        case sstaltertrigger: {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            gst = EFindSqlStateType.ststoredprocedure;
                                            break;
                                        }
                                        case sstmssqlgo: {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                            gst = EFindSqlStateType.stnormal;
                                            break;
                                        }
                                        default: {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            gst = EFindSqlStateType.stsql;
                                            break;
                                        }
                                    }
                                } else if (ast.tokencode == 351) {
                                    this.gcurrentsqlstatement = new TMssqlBlock(this.dbVendor);
                                    this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstmssqlblock;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    gst = EFindSqlStateType.stblock;
                                } else if (this.sqlstatements.size() == 0) {
                                    gst = EFindSqlStateType.stsql;
                                    (this.gcurrentsqlstatement = new TMssqlExecute(this.dbVendor)).addtokentolist(ast);
                                } else if (this.sqlstatements.get(this.sqlstatements.size() - 1).sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                    gst = EFindSqlStateType.stsql;
                                    (this.gcurrentsqlstatement = new TMssqlExecute(this.dbVendor)).addtokentolist(ast);
                                }
                                if (!TBaseType.assigned(this.gcurrentsqlstatement)) {
                                    this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                                    ast.tokentype = ETokenType.tttokenlizererrortoken;
                                    gst = EFindSqlStateType.sterror;
                                    this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                                    this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                break;
                            }
                        }
                        case stblock: {
                            if (TBaseType.assigned(lcnextsqlstatement)) {
                                if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    gst = EFindSqlStateType.stnormal;
                                } else {
                                    lcnextsqlstatement = null;
                                }
                            }
                            if (lcblocklevel == -1 && ast.tokencode == 59) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                                break;
                            }
                            if (gst != EFindSqlStateType.stblock) {
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            if (ast.tokencode == 351) {
                                final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                                if (!TBaseType.assigned(lcnextsolidtoken)) {
                                    ++lcblocklevel;
                                    break;
                                }
                                if (!TBaseType.mysametext(lcnextsolidtoken.astext, "tran") && !TBaseType.mysametext(lcnextsolidtoken.astext, "transaction")) {
                                    ++lcblocklevel;
                                    break;
                                }
                                break;
                            } else {
                                if (ast.tokencode == 316) {
                                    ++lcblocklevel;
                                    break;
                                }
                                if (ast.tokencode != 313) {
                                    break;
                                }
                                final boolean lcisendconversation = false;
                                final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                                if (lcisendconversation) {
                                    break;
                                }
                                if (lcblocklevel != 0) {
                                    --lcblocklevel;
                                    break;
                                }
                                if (this.gcurrentsqlstatement.sqlstatementtype != ESqlStatementType.sstmssqlif || !TBaseType.assigned(lcnextsolidtoken)) {
                                    break;
                                }
                                if (lcnextsolidtoken.tokencode == 349) {
                                    gst = EFindSqlStateType.stsql;
                                    break;
                                }
                                if (lcnextsolidtoken.tokentype != ETokenType.ttsemicolon) {
                                    break;
                                }
                                final TSourceToken lcnnextsolidtoken = this.sourcetokenlist.nextsolidtoken(lcnextsolidtoken.posinlist, 1, false);
                                if (TBaseType.assigned(lcnnextsolidtoken) && lcnnextsolidtoken.tokencode == 349) {
                                    gst = EFindSqlStateType.stsql;
                                    break;
                                }
                                break;
                            }
                        }
                        case stsql: {
                            if (ast.tokentype == ETokenType.ttsemicolon) {
                                boolean lcstillinsql = false;
                                if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif) {
                                    final TSourceToken lcnextsolidtoken = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                                    if (TBaseType.assigned(lcnextsolidtoken) && lcnextsolidtoken.tokencode == 349) {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        lcstillinsql = true;
                                    }
                                }
                                if (!lcstillinsql) {
                                    gst = EFindSqlStateType.stnormal;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    this.gcurrentsqlstatement.semicolonended = ast;
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    break;
                                }
                                break;
                            } else if (TBaseType.assigned(lcnextsqlstatement)) {
                                if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlgo) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    gst = EFindSqlStateType.stnormal;
                                    break;
                                }
                                switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                    case sstmssqlif:
                                    case sstmssqlwhile: {
                                        if (this.gcurrentsqlstatement.dummytag == 1) {
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) {
                                                this.gcurrentsqlstatement.dummytag = 1;
                                            } else {
                                                this.gcurrentsqlstatement.dummytag = 0;
                                            }
                                            lcnextsqlstatement = null;
                                            continue;
                                        }
                                        break;
                                    }
                                    case sstcreateschema: {
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        lcnextsqlstatement = null;
                                        continue;
                                    }
                                }
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                switch (this.gcurrentsqlstatement.sqlstatementtype) {
                                    case sstcreateprocedure:
                                    case sstcreatetrigger:
                                    case sstcreatefunction:
                                    case sstaltertrigger:
                                    case sstalterprocedure:
                                    case sstalterfunction: {
                                        gst = EFindSqlStateType.ststoredprocedure;
                                        continue;
                                    }
                                    default: {
                                        gst = EFindSqlStateType.stsql;
                                        continue;
                                    }
                                }
                            } else if (ast.tokencode == 351) {
                                if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) {
                                    gst = EFindSqlStateType.stblock;
                                    lcblocklevel = 0;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            } else {
                                if (ast.tokencode == 316) {
                                    ++case_end_nest;
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                if (ast.tokencode == 313) {
                                    if (case_end_nest > 0) {
                                        --case_end_nest;
                                    }
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                if (ast.tokencode != 349) {
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                if ((this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlif || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmssqlwhile) && case_end_nest == 0) {
                                    this.gcurrentsqlstatement.dummytag = 1;
                                    break;
                                }
                                break;
                            }
                        }
                        case ststoredprocedure: {
                            if (TBaseType.assigned(lcnextsqlstatement)) {
                                if (lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstalterfunction || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstcreateprocedure || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstcreatefunction || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstcreatetrigger || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstalterprocedure || lcnextsqlstatement.sqlstatementtype == ESqlStatementType.sstaltertrigger) {
                                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                    (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                    gst = EFindSqlStateType.ststoredprocedure;
                                    break;
                                }
                                gst = EFindSqlStateType.ststoredprocedurebody;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                lcnextsqlstatement = null;
                            }
                            if (gst != EFindSqlStateType.ststoredprocedure) {
                                break;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            if (ast.tokencode == 351) {
                                gst = EFindSqlStateType.ststoredprocedurebody;
                                break;
                            }
                            if (ast.tokencode == 545) {
                                gst = EFindSqlStateType.ststoredprocedurebody;
                                break;
                            }
                            break;
                        }
                        case ststoredprocedurebody: {
                            if (TBaseType.assigned(lcnextsqlstatement)) {
                                switch (lcnextsqlstatement.sqlstatementtype) {
                                    case sstmssqlgo: {
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        gst = EFindSqlStateType.stnormal;
                                        break;
                                    }
                                    case sstcreateprocedure:
                                    case sstcreatetrigger:
                                    case sstcreatefunction:
                                    case sstaltertrigger:
                                    case sstalterprocedure:
                                    case sstalterfunction: {
                                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                        (this.gcurrentsqlstatement = lcnextsqlstatement).addtokentolist(ast);
                                        gst = EFindSqlStateType.ststoredprocedure;
                                        break;
                                    }
                                    default: {
                                        lcnextsqlstatement = null;
                                        break;
                                    }
                                }
                            }
                            if (gst == EFindSqlStateType.ststoredprocedurebody) {
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            break;
                        }
                    }
                }
            }
        }
        if (TBaseType.assigned(this.gcurrentsqlstatement) && gst != EFindSqlStateType.stnormal) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return errorcount;
    }

    int dosparksqlgetrawsqlstatements() {
        final int errorcount = 0;
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        boolean waitingDelimiter = false;
        this.userDelimiterStr = this.defaultDelimiterStr;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            final TSourceToken ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode == 394) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null) {
                    if (st1.tokencode == 40) {
                        ast.tokencode = 533;
                    } else if (st1.tokencode == 262) {
                        ast.tokencode = 532;
                    }
                }
            } else if (ast.tokencode == 393) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null && st1.tokencode == 262) {
                    ast.tokencode = 534;
                }
            } else if (ast.tokencode == 395) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null) {
                    if (st1.tokencode == 262) {
                        ast.tokencode = 535;
                    } else if (st1.tokencode == 264 && st1.toString().startsWith("\"")) {
                        ast.tokencode = 535;
                        st1.tokencode = 262;
                    }
                }
            } else if (ast.tokencode == 416) {
                final TSourceToken leftParen = ast.searchToken(40, 1);
                if (leftParen != null) {
                    int k = leftParen.posinlist + 1;
                    boolean commaToken = false;
                    while (k < ast.container.size()) {
                        if (ast.container.get(k).tokencode == 41) {
                            break;
                        }
                        if (ast.container.get(k).tokencode == 44) {
                            commaToken = true;
                            break;
                        }
                        ++k;
                    }
                    if (commaToken) {
                        ast.tokencode = 544;
                    }
                }
            }
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        break;
                    } else {
                        if (ast.isFirstTokenOfLine() && (ast.tokencode == 543 || ast.tokencode == 288)) {
                            gst = EFindSqlStateType.stsqlplus;
                            (this.gcurrentsqlstatement = new TMySQLSource(this.dbVendor)).addtokentolist(ast);
                            break;
                        }
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                            final ESqlStatementType[] ses = {ESqlStatementType.sstmysqlcreateprocedure, ESqlStatementType.sstmysqlcreatefunction, ESqlStatementType.sstcreateprocedure, ESqlStatementType.sstcreatefunction, ESqlStatementType.sstcreatetrigger};
                            if (this.includesqlstatementtype(this.gcurrentsqlstatement.sqlstatementtype, ses)) {
                                gst = EFindSqlStateType.ststoredprocedure;
                                waitingDelimiter = false;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                this.curdelimiterchar = ';';
                            } else {
                                gst = EFindSqlStateType.stsql;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                            }
                        }
                        if (!TBaseType.assigned(this.gcurrentsqlstatement)) {
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        break;
                    }
                }
                case stsqlplus: {
                    if (ast.tokencode == 260) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon && this.gcurrentsqlstatement.sqlstatementtype != ESqlStatementType.sstmysqldelimiter) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (ast.toString().equalsIgnoreCase(this.userDelimiterStr)) {
                        gst = EFindSqlStateType.stnormal;
                        ast.tokencode = 59;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    if (ast.tokencode == 260 && this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmysqldelimiter) {
                        gst = EFindSqlStateType.stnormal;
                        this.userDelimiterStr = "";
                        for (int j = 0; j < this.gcurrentsqlstatement.sourcetokenlist.size(); ++j) {
                            final TSourceToken st2 = this.gcurrentsqlstatement.sourcetokenlist.get(j);
                            if (st2.tokencode != 536 && st2.tokencode != 260 && st2.tokencode != 259) {
                                if (st2.tokencode != 325) {
                                    this.userDelimiterStr += st2.toString();
                                }
                            }
                        }
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    break;
                }
                case ststoredprocedure: {
                    if (waitingDelimiter) {
                        if (this.userDelimiterStr.equalsIgnoreCase(ast.toString())) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement.semicolonended = ast;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        if (this.userDelimiterStr.startsWith(ast.toString())) {
                            String lcstr = ast.toString();
                            for (int k = ast.posinlist + 1; k < ast.container.size(); ++k) {
                                final TSourceToken st3 = ast.container.get(k);
                                if (st3.tokencode == 536 || st3.tokencode == 260) {
                                    break;
                                }
                                if (st3.tokencode == 259) {
                                    break;
                                }
                                lcstr += st3.toString();
                            }
                            if (this.userDelimiterStr.equalsIgnoreCase(lcstr)) {
                                for (int k = ast.posinlist; k < ast.container.size(); ++k) {
                                    final TSourceToken st3 = ast.container.get(k);
                                    if (st3.tokencode == 536 || st3.tokencode == 260) {
                                        break;
                                    }
                                    if (st3.tokencode == 259) {
                                        break;
                                    }
                                    ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                                }
                                gst = EFindSqlStateType.stnormal;
                                this.gcurrentsqlstatement.semicolonended = ast;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                        }
                    }
                    if (ast.tokencode == 351) {
                        waitingDelimiter = true;
                    }
                    if (this.userDelimiterStr.equals(";") || !waitingDelimiter) {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokentype == ETokenType.ttsemicolon) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement.semicolonended = ast;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        break;
                    } else {
                        if (ast.toString().equals(this.userDelimiterStr)) {
                            ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        if (ast.tokentype == ETokenType.ttsemicolon && this.userDelimiterStr.equals(";")) {
                            final TSourceToken lcprevtoken = ast.container.nextsolidtoken(ast, -1, false);
                            if (lcprevtoken != null && lcprevtoken.tokencode == 313) {
                                gst = EFindSqlStateType.stnormal;
                                this.gcurrentsqlstatement.semicolonended = ast;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                        }
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                }
            }
        }
        if (TBaseType.assigned(this.gcurrentsqlstatement) && (gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return errorcount;
    }

    int domysqlgetrawsqlstatements() {
        final int errorcount = 0;
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        boolean waitingDelimiter = false;
        this.userDelimiterStr = this.defaultDelimiterStr;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            final TSourceToken ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode == 394) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null) {
                    if (st1.tokencode == 40) {
                        ast.tokencode = 538;
                    } else if (st1.tokencode == 262) {
                        ast.tokencode = 539;
                    }
                }
            } else if (ast.tokencode == 393) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null && st1.tokencode == 262) {
                    ast.tokencode = 540;
                }
            } else if (ast.tokencode == 395) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null) {
                    if (st1.tokencode == 262) {
                        ast.tokencode = 553;
                    } else if (st1.tokencode == 264 && st1.toString().startsWith("\"")) {
                        ast.tokencode = 553;
                        st1.tokencode = 262;
                    }
                }
            } else if (ast.tokencode == 554) {
                final TSourceToken st1 = ast.nextSolidToken();
                if (st1 != null) {
                    if (st1.tokencode != 40) {
                        ast.tokencode = 264;
                    }
                }
            } else if (ast.tokencode == 541) {
                boolean isIdent = true;
                TSourceToken st2 = ast.nextSolidToken();
                if (st2 != null && st2.tokencode == 40) {
                    isIdent = false;
                }
                st2 = ast.prevSolidToken();
                if (st2 != null && (st2.tokencode == 542 || st2.tokencode == 552)) {
                    isIdent = false;
                }
                if (isIdent) {
                    ast.tokencode = 264;
                }
            } else if (ast.tokencode == 416) {
                final TSourceToken leftParen = ast.searchToken(40, 1);
                if (leftParen != null) {
                    int k = leftParen.posinlist + 1;
                    int nested = 1;
                    boolean commaToken = false;
                    while (k < ast.container.size()) {
                        if (ast.container.get(k).tokencode == 40) {
                            ++nested;
                        }
                        if (ast.container.get(k).tokencode == 41 && --nested == 0) {
                            break;
                        }
                        if (ast.container.get(k).tokencode == 44 && nested == 1) {
                            commaToken = true;
                            break;
                        }
                        ++k;
                    }
                    if (commaToken) {
                        ast.tokencode = 544;
                    }
                }
            }
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        break;
                    } else {
                        if (ast.isFirstTokenOfLine() && ast.toString().equalsIgnoreCase(this.userDelimiterStr)) {
                            ast.tokencode = 59;
                            break;
                        }
                        if (ast.isFirstTokenOfLine() && (ast.tokencode == 543 || ast.tokencode == 288)) {
                            gst = EFindSqlStateType.stsqlplus;
                            (this.gcurrentsqlstatement = new TMySQLSource(this.dbVendor)).addtokentolist(ast);
                            break;
                        }
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                            final ESqlStatementType[] ses = {ESqlStatementType.sstmysqlcreateprocedure, ESqlStatementType.sstmysqlcreatefunction, ESqlStatementType.sstcreateprocedure, ESqlStatementType.sstcreatefunction, ESqlStatementType.sstcreatetrigger};
                            if (this.includesqlstatementtype(this.gcurrentsqlstatement.sqlstatementtype, ses)) {
                                gst = EFindSqlStateType.ststoredprocedure;
                                waitingDelimiter = false;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                this.curdelimiterchar = ';';
                            } else {
                                gst = EFindSqlStateType.stsql;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                            }
                        }
                        if (!TBaseType.assigned(this.gcurrentsqlstatement)) {
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        break;
                    }
                }
                case stsqlplus: {
                    if (ast.tokencode == 260) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon && this.gcurrentsqlstatement.sqlstatementtype != ESqlStatementType.sstmysqldelimiter) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (ast.toString().equalsIgnoreCase(this.userDelimiterStr)) {
                        gst = EFindSqlStateType.stnormal;
                        ast.tokencode = 59;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (ast.tokencode == 258 && ast.toString().trim().endsWith(TBaseType.sqlflow_stmt_delimiter_str)) {
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    if (ast.tokencode == 260 && this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstmysqldelimiter) {
                        gst = EFindSqlStateType.stnormal;
                        this.userDelimiterStr = "";
                        for (int j = 0; j < this.gcurrentsqlstatement.sourcetokenlist.size(); ++j) {
                            final TSourceToken st3 = this.gcurrentsqlstatement.sourcetokenlist.get(j);
                            if (st3.tokencode != 536 && st3.tokencode != 260 && st3.tokencode != 259) {
                                if (st3.tokencode != 325) {
                                    this.userDelimiterStr += st3.toString();
                                }
                            }
                        }
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    break;
                }
                case ststoredprocedure: {
                    if (gst == EFindSqlStateType.ststoredprocedure && ast.tokencode == 258 && ast.toString().trim().endsWith(TBaseType.sqlflow_stmt_delimiter_str)) {
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (waitingDelimiter) {
                        if (this.userDelimiterStr.equalsIgnoreCase(ast.toString())) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement.semicolonended = ast;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        if (this.userDelimiterStr.startsWith(ast.toString())) {
                            String lcstr = ast.toString();
                            for (int k = ast.posinlist + 1; k < ast.container.size(); ++k) {
                                final TSourceToken st4 = ast.container.get(k);
                                if (st4.tokencode == 536 || st4.tokencode == 260) {
                                    break;
                                }
                                if (st4.tokencode == 259) {
                                    break;
                                }
                                lcstr += st4.toString();
                            }
                            if (this.userDelimiterStr.equalsIgnoreCase(lcstr)) {
                                for (int k = ast.posinlist; k < ast.container.size(); ++k) {
                                    final TSourceToken st4 = ast.container.get(k);
                                    if (st4.tokencode == 536 || st4.tokencode == 260) {
                                        break;
                                    }
                                    if (st4.tokencode == 259) {
                                        break;
                                    }
                                    ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                                }
                                gst = EFindSqlStateType.stnormal;
                                this.gcurrentsqlstatement.semicolonended = ast;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                        }
                    }
                    if (ast.tokencode == 351) {
                        waitingDelimiter = true;
                    }
                    if (this.userDelimiterStr.equals(";") || !waitingDelimiter) {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokentype == ETokenType.ttsemicolon) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement.semicolonended = ast;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        break;
                    } else {
                        if (ast.toString().equals(this.userDelimiterStr)) {
                            ast.tokenstatus = ETokenStatus.tsignorebyyacc;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        if (ast.tokentype == ETokenType.ttsemicolon && this.userDelimiterStr.equals(";")) {
                            final TSourceToken lcprevtoken = ast.container.nextsolidtoken(ast, -1, false);
                            if (lcprevtoken != null && lcprevtoken.tokencode == 313) {
                                gst = EFindSqlStateType.stnormal;
                                this.gcurrentsqlstatement.semicolonended = ast;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                break;
                            }
                        }
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                }
            }
        }
        if (TBaseType.assigned(this.gcurrentsqlstatement) && (gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return errorcount;
    }

    int dodb2getrawsqlstatements() {
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        final int errorcount = 0;
        int waitingEnds = 0;
        boolean waitingForFirstBegin = false;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            final TSourceToken ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode == 315) {
                final TSourceToken st1 = ast.searchToken("global", 1);
                if (st1 != null) {
                    ast.tokencode = 535;
                }
            } else if (ast.tokencode == 396 || ast.tokencode == 536 || ast.tokencode == 540) {
                final TSourceToken st1 = ast.searchToken(46, 1);
                if (st1 != null) {
                    ast.tokencode = 264;
                }
            } else if (ast.tokencode == 543 || ast.tokencode == 544) {
                final TSourceToken st1 = ast.searchToken(545, -2);
                if (st1 == null) {
                    ast.tokencode = 264;
                }
            }
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        break;
                    } else {
                        if (ast.tokencode == 273) {
                            gst = EFindSqlStateType.stsqlplus;
                            (this.gcurrentsqlstatement = new TSqlplusCmdStatement(this.dbVendor)).addtokentolist(ast);
                            break;
                        }
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                            final ESqlStatementType[] ses = {ESqlStatementType.sstdb2declarecursor, ESqlStatementType.sstcreateprocedure, ESqlStatementType.sstcreatefunction, ESqlStatementType.sstcreatetrigger, ESqlStatementType.sst_plsql_block};
                            if (this.includesqlstatementtype(this.gcurrentsqlstatement.sqlstatementtype, ses)) {
                                gst = EFindSqlStateType.ststoredprocedure;
                                waitingEnds = 1;
                                waitingForFirstBegin = true;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstcreateprocedure || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstcreatefunction || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstcreatetrigger) {
                                    this.curdelimiterchar = ';';
                                }
                            } else if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstdb2scriptOption) {
                                gst = EFindSqlStateType.stnormal;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            } else {
                                gst = EFindSqlStateType.stsql;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                            }
                        }
                        if (!TBaseType.assigned(this.gcurrentsqlstatement)) {
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        break;
                    }
                }
                case stsqlplus: {
                    if (ast.insqlpluscmd) {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        break;
                    }
                    gst = EFindSqlStateType.stnormal;
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                    break;
                }
                case stsql: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case ststoredprocedure: {
                    this.nextStmt = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                    if (this.nextStmt != null && (this.nextStmt.sqlstatementtype == ESqlStatementType.sstcreateprocedure || this.nextStmt.sqlstatementtype == ESqlStatementType.sstcreatefunction || this.nextStmt.sqlstatementtype == ESqlStatementType.sstcreatetrigger)) {
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        this.gcurrentsqlstatement = this.nextStmt;
                        gst = EFindSqlStateType.ststoredprocedure;
                        waitingEnds = 1;
                        waitingForFirstBegin = true;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.curdelimiterchar = ';';
                        break;
                    }
                    if (this.curdelimiterchar != this.delimiterchar && (ast.tokencode == 351 || ast.tokencode == 315)) {
                        this.curdelimiterchar = this.delimiterchar;
                    }
                    if (this.curdelimiterchar == ';') {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokentype == ETokenType.ttsemicolon) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement._semicolon = ast;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        break;
                    } else {
                        char ch;
                        if (ast.astext.length() == 1) {
                            ch = ast.astext.charAt(0);
                        } else if (ast.astext.length() > 1 && ast.issolidtoken()) {
                            ch = ast.astext.charAt(ast.astext.length() - 1);
                        } else {
                            ch = ' ';
                        }
                        if (ch == this.curdelimiterchar) {
                            if (ast.astext.length() > 1) {
                                final String lcstr = ast.astext.substring(0, ast.astext.length() - 1);
                                final int c;
                                if ((c = this.flexer.getkeywordvalue(lcstr)) > 0) {
                                    ast.tokencode = c;
                                }
                            } else {
                                this.gcurrentsqlstatement._semicolon = ast;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokencode == 316 || ast.tokencode == 306 || ast.tokencode == 305 || ast.tokencode == 460 || ast.tokencode == 494 || ast.tokencode == 490) {
                            final TSourceToken nextst = ast.nextSolidToken();
                            if (nextst != null && nextst.tokencode != 59) {
                                ++waitingEnds;
                            }
                        } else if (ast.tokencode == 351) {
                            if (waitingForFirstBegin) {
                                waitingForFirstBegin = false;
                            } else {
                                ++waitingEnds;
                            }
                        } else if (ast.tokencode == 313) {
                            --waitingEnds;
                        }
                        if (ast.tokentype == ETokenType.ttsemicolon && waitingEnds == 0) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement._semicolon = ast;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                        break;
                    }
                }
            }
        }
        if (TBaseType.assigned(this.gcurrentsqlstatement) && (gst == EFindSqlStateType.stsqlplus || gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return errorcount;
    }

    int doteradatagetrawsqlstatements() {
        this.gcurrentsqlstatement = null;
        EFindSqlStateType gst = EFindSqlStateType.stnormal;
        int lcNestedParens = 0;
        int lcNestedBeginEnd = 0;
        int lcNestedCase = 0;
        int lcNestedSample = 0;
        TSourceToken lcprevst = null;
        TSourceToken lcnextst = null;
        TSourceToken lcnextst2 = null;
        TSourceToken lcnextst3 = null;
        TSourceToken lcprevsolidtoken = null;
        TSourceToken ast = null;
        final TSourceToken lcprevst2 = null;
        final int errorcount = 0;
        boolean inBTEQComment = false;
        boolean isContinueBTEQCmd = false;
        for (int i = 0; i < this.sourcetokenlist.size(); ++i) {
            if (ast != null && ast.issolidtoken()) {
                lcprevsolidtoken = ast;
            }
            ast = this.sourcetokenlist.get(i);
            this.sourcetokenlist.curpos = i;
            if (ast.tokencode != 393 && ast.tokencode != 394) {
                if (ast.tokencode != 395) {
                    if (ast.tokencode == 40) {
                        lcnextst = this.sourcetokenlist.nextsolidtoken(i, 1, false);
                        lcprevst = this.getprevsolidtoken(ast);
                        if (lcprevst != null && (lcprevst.tokencode == 560 || lcprevst.tokencode == 396)) {
                            lcnextst = null;
                        }
                        if (lcprevst != null && TFunctionCall.isBuiltIn(lcprevst.toString(), EDbVendor.dbvteradata) && lcprevst.tokencode != 313 && lcprevst.tokencode != 393 && lcprevst.tokencode != 394 && lcprevst.tokencode != 395 && lcprevst.tokencode != 580 && !lcprevst.toString().equalsIgnoreCase("current_date") && !lcprevst.toString().equalsIgnoreCase("current_time") && !lcprevst.toString().equalsIgnoreCase("current_timestamp")) {
                            if (!lcprevst.toString().equalsIgnoreCase("user")) {
                                lcnextst = null;
                            }
                        }
                        if (lcnextst != null) {
                            final EDataType dataType = TTypeName.searchTeradataTypeByName(lcnextst.toString());
                            if (dataType != null && lcprevst != null && lcprevst.tokencode != 559) {
                                ast.tokencode = 558;
                                lcnextst2 = this.sourcetokenlist.nextsolidtoken(i, 2, false);
                                lcnextst3 = this.sourcetokenlist.nextsolidtoken(i, 3, false);
                                if (lcnextst2.tokencode == 44) {
                                    final TSourceToken st1 = lcnextst3;
                                    final TSourceToken st2 = this.sourcetokenlist.nextsolidtoken(i, 4, false);
                                    if (TDatatypeAttribute.searchDataTypeAttributeByName(st1, st2) == null) {
                                        ast.tokencode = 40;
                                    }
                                } else if (lcnextst2 != null && lcnextst3 != null) {
                                    switch (dataType) {
                                        case date_t:
                                        case time_t: {
                                            if (lcnextst2.tokencode == 41) {
                                                break;
                                            }
                                            if (lcnextst2.tokencode == 40 && lcnextst3.tokencode == 263) {
                                                break;
                                            }
                                            ast.tokencode = 40;
                                            break;
                                        }
                                        case timestamp_t:
                                        case interval_t: {
                                            if (lcnextst2.tokencode == 262) {
                                                ast.tokencode = 40;
                                                break;
                                            }
                                            break;
                                        }
                                        case char_t: {
                                            if (lcnextst3.tokencode != 263) {
                                                ast.tokencode = 40;
                                                break;
                                            }
                                            break;
                                        }
                                    }
                                }
                            } else {
                                final TSourceToken st1 = lcnextst;
                                final TSourceToken st2 = this.sourcetokenlist.nextsolidtoken(i, 2, false);
                                if (TDatatypeAttribute.searchDataTypeAttributeByName(st1, st2) != null) {
                                    ast.tokencode = 558;
                                }
                            }
                        }
                    } else if (ast.tokencode == 306) {
                        final TSourceToken nextToken = ast.searchTokenAfterObjectName();
                        if (nextToken != null && nextToken.tokencode == 341) {
                            ast.tokencode = 563;
                        }
                    } else if (ast.tokencode == 564) {
                        final TSourceToken nextToken = ast.searchToken(40, 1);
                        if (nextToken != null) {
                            ast.tokencode = 565;
                        }
                    } else if (ast.tokencode == 570) {
                        final TSourceToken nextToken = ast.searchToken(40, 1);
                        if (nextToken == null) {
                            ast.tokencode = 264;
                        }
                    } else if (ast.tokencode == 559) {
                        final TSourceToken nextToken = ast.nextSolidToken();
                        if (nextToken == null) {
                            ast.tokencode = 264;
                        } else if (nextToken.tokencode != 40) {
                            if (nextToken.tokencode != 306) {
                                if (ast.prevSolidToken() == null) {
                                    ast.tokencode = 264;
                                } else if (!ast.prevSolidToken().toString().equalsIgnoreCase("anchor")) {
                                    ast.tokencode = 264;
                                }
                            }
                        }
                    } else if (ast.tokencode == 566) {
                        lcprevst = this.getprevsolidtoken(ast);
                        if (lcprevst != null && lcprevst.tokencode == 313) {
                            lcprevst.tokencode = 567;
                        }
                    } else if (ast.tokencode == 505) {
                        final TSourceToken nextToken = ast.searchToken(40, 1);
                        if (nextToken != null) {
                            ast.tokencode = 264;
                        }
                    } else if (ast.tokencode == 350) {
                        final TSourceToken nextToken = ast.nextSolidToken();
                        if (nextToken != null && (nextToken.tokencode == 351 || nextToken.tokencode == 313)) {
                            nextToken.tokencode = 264;
                        }
                    } else if (ast.tokencode == 315) {
                        final TSourceToken nextToken = ast.nextSolidToken();
                        if (nextToken != null) {
                            final TSourceToken nextnextToken = nextToken.nextSolidToken();
                            if (nextnextToken != null) {
                                if (nextnextToken.toString().equalsIgnoreCase("cursor") || nextnextToken.toString().equalsIgnoreCase("insensitive") || nextnextToken.toString().equalsIgnoreCase("scroll") || nextnextToken.toString().equalsIgnoreCase("no")) {
                                    nextToken.tokencode = 571;
                                } else if (nextnextToken.toString().equalsIgnoreCase("condition")) {
                                    nextToken.tokencode = 572;
                                }
                            }
                        }
                    } else if (ast.tokencode == 316 && ast.tag == 0 && ast.posinlist + 1 < this.sourcetokenlist.size()) {
                        int lcNest = 1;
                        for (int m = ast.posinlist + 1; m < this.sourcetokenlist.size() - 1; ++m) {
                            final TSourceToken st3 = this.sourcetokenlist.get(m);
                            if (st3.tokencode == 316) {
                                st3.tag = 1;
                                ++lcNest;
                            }
                            if (st3.tokencode == 313 && --lcNest == 0) {
                                final TSourceToken caseToken = st3.nextSolidToken();
                                if (caseToken != null && caseToken.tokencode == 316) {
                                    ast.tokencode = 573;
                                    caseToken.tag = 1;
                                    break;
                                }
                            }
                        }
                    } else if (ast.tokencode == 423) {
                        final TSourceToken prevSolidToken = ast.prevSolidToken();
                        if (prevSolidToken != null && prevSolidToken.tokencode == 311) {
                            prevSolidToken.tokencode = 574;
                        }
                    } else if (ast.tokencode == 275) {
                        final TSourceToken prevSolidToken = ast.prevSolidToken();
                        if (prevSolidToken != null && prevSolidToken.tokencode == 332) {
                            ast.tokencode = 264;
                        }
                    }
                }
            }
            switch (gst) {
                case sterror: {
                    if (ast.tokentype == ETokenType.ttsemicolon) {
                        this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    this.gcurrentsqlstatement.sourcetokenlist.add(ast);
                    break;
                }
                case stMultiLoadCmd: {
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    if (ast.tokencode == 59 && ast.isLastTokenOfLine()) {
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    if (ast.isLastTokenOfLine()) {
                        String cmdstr = this.gcurrentsqlstatement.sourcetokenlist.get(0).toString();
                        if (this.gcurrentsqlstatement.sourcetokenlist.size() > 1) {
                            cmdstr += this.gcurrentsqlstatement.sourcetokenlist.get(1).toString();
                        }
                        if (cmdstr.toLowerCase().startsWith(".if") || cmdstr.toLowerCase().startsWith(".set") || cmdstr.toLowerCase().startsWith("set")) {
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            gst = EFindSqlStateType.stnormal;
                        }
                        break;
                    }
                    break;
                }
                case stFastExportCmd: {
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    if (ast.tokencode == 59 && ast.isLastTokenOfLine()) {
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                    }
                    boolean findSQL = false;
                    final TSourceToken nextst = ast.nextToken();
                    if (nextst == null || nextst.tokentype != ETokenType.ttreturn) {
                        break;
                    }
                    findSQL = (this.sqlcmds.issql(ast.nextSolidToken(), this.dbVendor, gst, this.gcurrentsqlstatement) != null);
                    if (findSQL) {
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    break;
                }
                case stFastLoadCmd: {
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    if (ast.tokencode == 59 && ast.isLastTokenOfLine()) {
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    }
                    if (ast.tokencode == 260) {
                        final TSourceToken nextst2 = ast.nextSolidToken();
                        if (nextst2 != null) {
                            if (nextst2.tokencode == 282) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stFastLoadCmd;
                            } else if (nextst2.tokencode == 46) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stFastLoadCmd;
                            } else if (this.sqlcmds.issql(nextst2, this.dbVendor, gst, this.gcurrentsqlstatement) != null) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                            }
                        }
                        break;
                    }
                    break;
                }
                case stBTEQCmd: {
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    if (ast.tokencode == 260) {
                        if (isContinueBTEQCmd) {
                            isContinueBTEQCmd = false;
                            break;
                        }
                        if (((TTeradataBTEQCmd) this.gcurrentsqlstatement).getBteqCmdType() == EBTEQCmdType.LOGON) {
                            boolean findSQL = false;
                            findSQL = (this.sqlcmds.issql(ast.nextSolidToken(), this.dbVendor, gst, this.gcurrentsqlstatement) != null);
                            if (findSQL) {
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                                gst = EFindSqlStateType.stnormal;
                            }
                            break;
                        }
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        gst = EFindSqlStateType.stnormal;
                        break;
                    } else if (ast.tokencode == 45 && ast.isLastTokenOfLine()) {
                        if (!inBTEQComment) {
                            isContinueBTEQCmd = true;
                            break;
                        }
                        break;
                    } else {
                        if (ast.tokencode == 259) {
                            break;
                        }
                        if (ast.tokencode == 59) {
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            boolean findNewCmdInSameLine = false;
                            if (!ast.isLastTokenOfLine()) {
                                final TSourceToken nextst = ast.nextSolidToken();
                                if (nextst != null && nextst.tokencode == 46) {
                                    final TSourceToken nextst3 = nextst.nextSolidToken();
                                    if (nextst3 != null) {
                                        String searchStr = null;
                                        if (nextst3.tokencode == 325) {
                                            final TSourceToken nextst4 = nextst3.nextSolidToken();
                                            if (nextst4 != null) {
                                                searchStr = nextst4.astext;
                                            }
                                        } else {
                                            searchStr = nextst3.astext;
                                        }
                                        final EBTEQCmdType ebteqCmdType = TTeradataHelper.searchBTEQTypeByName(searchStr);
                                        if (ebteqCmdType != null) {
                                            this.gcurrentsqlstatement = new TTeradataBTEQCmd(this.dbVendor);
                                            ((TTeradataBTEQCmd) this.gcurrentsqlstatement).setBteqCmdType(ebteqCmdType);
                                            this.gcurrentsqlstatement.addtokentolist(ast);
                                            findNewCmdInSameLine = true;
                                        }
                                    }
                                }
                            }
                            if (findNewCmdInSameLine) {
                                gst = EFindSqlStateType.stBTEQCmd;
                            } else {
                                gst = EFindSqlStateType.stnormal;
                            }
                            break;
                        }
                        isContinueBTEQCmd = (ast.tokencode == 42 && false);
                        break;
                    }
                }
                case stnormal: {
                    if (ast.tokencode == 258 || ast.tokencode == 257 || ast.tokencode == 259 || ast.tokencode == 260 || ast.tokentype == ETokenType.ttsemicolon) {
                        if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                        }
                        if (lcprevsolidtoken != null && ast.tokentype == ETokenType.ttsemicolon && lcprevsolidtoken.tokentype == ETokenType.ttsemicolon) {
                            ast.tokentype = ETokenType.ttsimplecomment;
                            ast.tokencode = 258;
                            break;
                        }
                        break;
                    } else {
                        if (ast.tokencode == 46 && ast.isFirstTokenOfLine()) {
                            final TSourceToken nextst2 = ast.nextSolidToken();
                            TSourceToken cmdToken = null;
                            if (nextst2 != null) {
                                String searchStr2 = null;
                                if (nextst2.tokencode == 325) {
                                    final TSourceToken nextst5 = nextst2.nextSolidToken();
                                    if (nextst5 != null) {
                                        searchStr2 = nextst5.astext;
                                        cmdToken = nextst5;
                                    }
                                } else {
                                    searchStr2 = nextst2.astext;
                                    cmdToken = nextst2;
                                }
                                EBTEQCmdType ebteqCmdType2 = TTeradataHelper.searchBTEQTypeByName(searchStr2);
                                if (ebteqCmdType2 != null) {
                                    switch (ebteqCmdType2) {
                                        case EXPORT: {
                                            final TSourceToken nextst6 = cmdToken.nextSolidToken();
                                            if (nextst6 == null || nextst6.astext.equalsIgnoreCase("data") || nextst6.astext.equalsIgnoreCase("indicdata") || nextst6.astext.equalsIgnoreCase("report") || nextst6.astext.equalsIgnoreCase("dif")) {
                                                break;
                                            }
                                            if (nextst6.astext.equalsIgnoreCase("reset")) {
                                                break;
                                            }
                                            ebteqCmdType2 = null;
                                            break;
                                        }
                                        case IMPORT: {
                                            final TSourceToken nextst6 = cmdToken.nextSolidToken();
                                            if (nextst6 == null || nextst6.astext.equalsIgnoreCase("data") || nextst6.astext.equalsIgnoreCase("indicdata") || nextst6.astext.equalsIgnoreCase("vartext") || nextst6.astext.equalsIgnoreCase("reset")) {
                                                break;
                                            }
                                            if (nextst6.astext.equalsIgnoreCase("ddname")) {
                                                break;
                                            }
                                            ebteqCmdType2 = null;
                                            break;
                                        }
                                        case SESSION: {
                                            final TSourceToken nextst6 = cmdToken.nextSolidToken();
                                            if (nextst6 == null) {
                                                break;
                                            }
                                            if (nextst6.astext.equalsIgnoreCase("charset")) {
                                                ebteqCmdType2 = EBTEQCmdType.SESSION_CHARSET;
                                                break;
                                            }
                                            if (nextst6.astext.equalsIgnoreCase("RESPBUFLEN")) {
                                                ebteqCmdType2 = EBTEQCmdType.SESSION_RESPBUFLEN;
                                                break;
                                            }
                                            if (nextst6.astext.equalsIgnoreCase("SQLFLAG")) {
                                                ebteqCmdType2 = EBTEQCmdType.SESSION_SQLFLAG;
                                                break;
                                            }
                                            if (nextst6.astext.equalsIgnoreCase("TRANSACTION")) {
                                                ebteqCmdType2 = EBTEQCmdType.SESSION_TRANSACTION;
                                                break;
                                            }
                                            if (nextst6.astext.equalsIgnoreCase("TRANS")) {
                                                ebteqCmdType2 = EBTEQCmdType.SESSION_TRANSACTION;
                                                break;
                                            }
                                            if (nextst6.astext.equalsIgnoreCase("TWORESPBUFS")) {
                                                ebteqCmdType2 = EBTEQCmdType.SESSION_TWORESPBUFS;
                                                break;
                                            }
                                            ebteqCmdType2 = null;
                                            break;
                                        }
                                        case SHOW: {
                                            final TSourceToken nextst6 = cmdToken.nextSolidToken();
                                            if (nextst6 == null) {
                                                break;
                                            }
                                            if (nextst6.astext.equalsIgnoreCase("CONTROLS")) {
                                                ebteqCmdType2 = EBTEQCmdType.SHOW_CONTROLS;
                                                break;
                                            }
                                            if (nextst6.astext.equalsIgnoreCase("CONTROL")) {
                                                ebteqCmdType2 = EBTEQCmdType.SHOW_CONTROLS;
                                                break;
                                            }
                                            if (nextst6.astext.equalsIgnoreCase("ERRORMAP")) {
                                                ebteqCmdType2 = EBTEQCmdType.SHOW_ERRORMAP;
                                                break;
                                            }
                                            if (nextst6.astext.equalsIgnoreCase("VERSION")) {
                                                ebteqCmdType2 = EBTEQCmdType.SHOW_VERSIONS;
                                                break;
                                            }
                                            if (nextst6.astext.equalsIgnoreCase("VERSIONS")) {
                                                ebteqCmdType2 = EBTEQCmdType.SHOW_VERSIONS;
                                                break;
                                            }
                                            break;
                                        }
                                    }
                                    if (ebteqCmdType2 != null) {
                                        this.gcurrentsqlstatement = new TTeradataBTEQCmd(this.dbVendor);
                                        ((TTeradataBTEQCmd) this.gcurrentsqlstatement).setBteqCmdType(ebteqCmdType2);
                                        this.gcurrentsqlstatement.addtokentolist(ast);
                                        gst = EFindSqlStateType.stBTEQCmd;
                                        break;
                                    }
                                }
                                gst = ((TLexerTeradata) this.getFlexer()).cmdType(nextst2.astext);
                                boolean foundCmd = false;
                                switch (gst) {
                                    case stMultiLoadCmd: {
                                        this.gcurrentsqlstatement = new TTeradataMultiLoadCmd(this.dbVendor);
                                        gst = EFindSqlStateType.stMultiLoadCmd;
                                        foundCmd = true;
                                        break;
                                    }
                                    case stFastExportCmd: {
                                        this.gcurrentsqlstatement = new TTeradataFastExportCmd(this.dbVendor);
                                        gst = EFindSqlStateType.stFastExportCmd;
                                        foundCmd = true;
                                        break;
                                    }
                                    case stFastLoadCmd: {
                                        this.gcurrentsqlstatement = new TTeradataFastLoadCmd(this.dbVendor);
                                        gst = EFindSqlStateType.stFastLoadCmd;
                                        foundCmd = true;
                                        break;
                                    }
                                }
                                if (foundCmd) {
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                            }
                        } else {
                            if (ast.tokencode == 42 && ast.isFirstTokenOfLine()) {
                                gst = EFindSqlStateType.stBTEQCmd;
                                inBTEQComment = true;
                                this.gcurrentsqlstatement = new TTeradataBTEQCmd(this.dbVendor);
                                ((TTeradataBTEQCmd) this.gcurrentsqlstatement).setBteqCmdType(EBTEQCmdType.comment);
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            if (ast.tokencode == 61 && ast.isFirstTokenOfLine()) {
                                final TSourceToken st4 = ast.prevSolidToken();
                                if (st4 != null && st4.tokencode == 59) {
                                    gst = EFindSqlStateType.stBTEQCmd;
                                    this.gcurrentsqlstatement = new TTeradataBTEQCmd(this.dbVendor);
                                    ((TTeradataBTEQCmd) this.gcurrentsqlstatement).setFindSqlStateType(gst);
                                    this.gcurrentsqlstatement.addtokentolist(ast);
                                    break;
                                }
                            }
                        }
                        this.gcurrentsqlstatement = this.sqlcmds.issql(ast, this.dbVendor, gst, this.gcurrentsqlstatement);
                        if (TBaseType.assigned(this.gcurrentsqlstatement)) {
                            final ESqlStatementType[] ses = {ESqlStatementType.sstcreateprocedure, ESqlStatementType.sstteradatacreatefunction, ESqlStatementType.sstcreatetrigger};
                            if (this.includesqlstatementtype(this.gcurrentsqlstatement.sqlstatementtype, ses)) {
                                gst = EFindSqlStateType.ststoredprocedure;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstcreateprocedure || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstteradatacreatefunction || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstcreatetrigger) {
                                    this.curdelimiterchar = ';';
                                }
                            } else {
                                gst = EFindSqlStateType.stsql;
                                this.gcurrentsqlstatement.addtokentolist(ast);
                            }
                            lcNestedParens = 0;
                        }
                        if (!TBaseType.assigned(this.gcurrentsqlstatement) && ast.isFirstTokenOfLine()) {
                            gst = ((TLexerTeradata) this.getFlexer()).cmdType(ast.astext);
                            if (gst == EFindSqlStateType.stMultiLoadCmd || gst == EFindSqlStateType.stFastLoadCmd || gst == EFindSqlStateType.stFastExportCmd) {
                                this.gcurrentsqlstatement = new TTeradataBTEQCmd(this.dbVendor);
                                ((TTeradataBTEQCmd) this.gcurrentsqlstatement).setFindSqlStateType(gst);
                                this.gcurrentsqlstatement.addtokentolist(ast);
                                break;
                            }
                            gst = EFindSqlStateType.stnormal;
                        }
                        if (!TBaseType.assigned(this.gcurrentsqlstatement)) {
                            this.syntaxErrors.add(new TSyntaxError(ast.astext, ast.lineNo, (ast.columnNo < 0L) ? 0L : ast.columnNo, "Error when tokenlize", EErrorType.spwarning, 10200, null, ast.posinlist));
                            ast.tokentype = ETokenType.tttokenlizererrortoken;
                            gst = EFindSqlStateType.sterror;
                            this.gcurrentsqlstatement = new TUnknownSqlStatement(this.dbVendor);
                            this.gcurrentsqlstatement.sqlstatementtype = ESqlStatementType.sstinvalid;
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            break;
                        }
                        break;
                    }
                }
                case stsql: {
                    boolean readyToEnd = true;
                    if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstteradatacreatemacro) {
                        if (ast.tokencode == 40 || ast.tokencode == 558) {
                            ++lcNestedParens;
                        }
                        if (ast.tokencode == 41 && --lcNestedParens < 0) {
                            lcNestedParens = 0;
                        }
                        readyToEnd = (lcNestedParens == 0);
                    }
                    if (ast.tokentype == ETokenType.ttsemicolon && readyToEnd) {
                        gst = EFindSqlStateType.stnormal;
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        this.gcurrentsqlstatement.semicolonended = ast;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    if (ast.tokencode == 258 && ast.toString().trim().endsWith(TBaseType.sqlflow_stmt_delimiter_str)) {
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    this.gcurrentsqlstatement.addtokentolist(ast);
                    break;
                }
                case ststoredprocedure: {
                    boolean readyToEnd = true;
                    if (ast.tokencode == 59) {
                        lcNestedSample = 0;
                        lcNestedCase = 0;
                    } else if (ast.tokencode == 316) {
                        ++lcNestedCase;
                        final TSourceToken prevst = ast.prevSolidToken();
                        if (prevst != null && prevst.tokencode == 313) {
                            --lcNestedCase;
                        }
                    } else if (ast.tokencode == 581) {
                        ++lcNestedSample;
                    }
                    if (this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstcreatetrigger || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstcreateprocedure || this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstcreatefunction) {
                        if (ast.tokencode == 40 || ast.tokencode == 558) {
                            ++lcNestedParens;
                        }
                        if (ast.tokencode == 41 && --lcNestedParens < 0) {
                            lcNestedParens = 0;
                        }
                        if (ast.tokencode == 351) {
                            ++lcNestedBeginEnd;
                        }
                        if (ast.tokencode == 313) {
                            boolean countThisEnd = true;
                            if (lcNestedSample > 0) {
                                --lcNestedSample;
                                countThisEnd = false;
                            } else if (lcNestedCase > 0) {
                                --lcNestedCase;
                                countThisEnd = false;
                            }
                            if (countThisEnd) {
                                final TSourceToken nt = ast.nextSolidToken();
                                if (nt != null) {
                                    countThisEnd = (nt.tokencode != 460 && nt.tokencode != 305 && nt.tokencode != 316 && nt.tokencode != 490 && nt.tokencode != 306 && nt.tokencode != 494);
                                }
                            }
                            if (countThisEnd && --lcNestedBeginEnd < 0) {
                                lcNestedBeginEnd = 0;
                            }
                        }
                        readyToEnd = (lcNestedParens == 0 && lcNestedBeginEnd == 0);
                    }
                    if (this.curdelimiterchar != this.delimiterchar) {
                        if (ast.tokencode == 351) {
                            this.curdelimiterchar = this.delimiterchar;
                        } else if (ast.tokencode == 276 && ast.container.nextsolidtoken(ast, 1, false).tokencode == 351) {
                            this.curdelimiterchar = this.delimiterchar;
                        }
                    }
                    if (this.curdelimiterchar == ';') {
                        this.gcurrentsqlstatement.addtokentolist(ast);
                        if (ast.tokentype == ETokenType.ttsemicolon & this.gcurrentsqlstatement.sqlstatementtype == ESqlStatementType.sstcreatetrigger & readyToEnd) {
                            gst = EFindSqlStateType.stnormal;
                            this.gcurrentsqlstatement._semicolon = ast;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            break;
                        }
                    } else {
                        char ch;
                        if (ast.astext.length() == 1) {
                            ch = ast.astext.charAt(0);
                        } else if (ast.astext.length() > 1) {
                            ch = ast.astext.charAt(ast.astext.length() - 1);
                        } else {
                            ch = ' ';
                        }
                        if (ast.tokencode != 257 && ast.tokencode != 258 && ch == this.curdelimiterchar && ast.isFirstTokenOfLine() && readyToEnd) {
                            if (ast.astext.length() > 1) {
                                final String lcstr = ast.astext.substring(0, ast.astext.length() - 1);
                                final int c;
                                if ((c = this.flexer.getkeywordvalue(lcstr)) > 0) {
                                    ast.tokencode = c;
                                }
                            } else {
                                this.gcurrentsqlstatement._semicolon = ast;
                            }
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        } else if (ast.searchToken(307, 1) != null && ast.searchToken(477, 4) != null && readyToEnd) {
                            gst = EFindSqlStateType.stnormal;
                            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        } else if (ast.tokencode == 59) {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                            boolean startNewStatement = false;
                            if (readyToEnd) {
                                startNewStatement = (this.sqlcmds.issql(ast.nextSolidToken(), this.dbVendor, gst, this.gcurrentsqlstatement) != null);
                            }
                            if (startNewStatement) {
                                gst = EFindSqlStateType.stnormal;
                                this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                            }
                        } else {
                            this.gcurrentsqlstatement.addtokentolist(ast);
                        }
                    }
                    if (gst == EFindSqlStateType.ststoredprocedure && ast.tokencode == 258 && ast.toString().trim().endsWith(TBaseType.sqlflow_stmt_delimiter_str)) {
                        gst = EFindSqlStateType.stnormal;
                        this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
                        break;
                    }
                    break;
                }
            }
        }
        if (TBaseType.assigned(this.gcurrentsqlstatement) && (gst == EFindSqlStateType.stsql || gst == EFindSqlStateType.stBTEQCmd || gst == EFindSqlStateType.ststoredprocedure || gst == EFindSqlStateType.sterror)) {
            this.doongetrawsqlstatementevent(this.gcurrentsqlstatement);
        }
        return errorcount;
    }

    int dogetrawsqlstatements() {
        this.sqlstatements.clear();
        if (this.sourcetokenlist.size() == 0) {
            return -1;
        }
        switch (this.dbVendor) {
            case dbvmssql:
            case dbvazuresql: {
                return this.domssqlgetrawsqlstatements();
            }
            case dbvsybase: {
                return this.dosybasegetrawsqlstatements();
            }
            case dbvinformix: {
                return this.doinformixgetrawsqlstatements();
            }
            case dbvoracle: {
                return this.dooraclegetrawsqlstatements();
            }
            case dbvdb2: {
                return this.dodb2getrawsqlstatements();
            }
            case dbvmysql: {
                return this.domysqlgetrawsqlstatements();
            }
            case dbvteradata: {
                return this.doteradatagetrawsqlstatements();
            }
            case dbvpostgresql: {
                return this.dopostgresqlgetrawsqlstatements();
            }
            case dbvredshift: {
                return this.doredshiftgetrawsqlstatements();
            }
            case dbvgreenplum: {
                return this.dogreenplumgetrawsqlstatements();
            }
            case dbvmdx: {
                return this.domdxgetrawsqlstatements();
            }
            case dbvnetezza: {
                return this.donetezzagetrawsqlstatements();
            }
            case dbvhive: {
                return this.dohivegetrawsqlstatements();
            }
            case dbvimpala: {
                return this.doimpalagetrawsqlstatements();
            }
            case dbvhana: {
                return this.dohanagetrawsqlstatements();
            }
            case dbvdax: {
                return this.dodaxgetrawsqlstatements();
            }
            case dbvodbc: {
                return this.doodbcgetrawsqlstatements();
            }
            case dbvvertica: {
                return this.doverticagetrawsqlstatements();
            }
            case dbvopenedge: {
                return this.domssqlgetrawsqlstatements();
            }
            case dbvcouchbase: {
                return this.docouchbasegetrawsqlstatements();
            }
            case dbvsnowflake: {
                final int i = this.dosnowflakegetrawsqlstatements();
                this.explandDollarString();
                return i;
            }
            case dbvbigquery: {
                return this.dobigquerygetrawsqlstatements();
            }
            case dbvsoql: {
                return this.dosoqlgetrawsqlstatements();
            }
            case dbvsparksql: {
                return this.dosparksqlgetrawsqlstatements();
            }
            case dbvpresto: {
                return this.doprestogetrawsqlstatements();
            }
            case dbvathena: {
                return this.doprestogetrawsqlstatements();
            }
            case dbvdatabricks: {
                return this.dodatabricksgetrawsqlstatements();
            }
            case dbvgaussdb: {
                return this.dogaussdbgetrawsqlstatements();
            }
            case dbvansi: {
                return this.doansigetrawsqlstatements();
            }
            default: {
                return this.domssqlgetrawsqlstatements();
            }
        }
    }

    public int getrawsqlstatements() {
        final int ret = this.readsql();
        if (ret != 0) {
            return ret;
        }
        this.dosqltexttotokenlist();
        return this.dogetrawsqlstatements();
    }

    public void tokenizeSqltext() {
        this.readsql();
        this.dosqltexttotokenlist();
    }

    void findAllSyntaxErrorsInPlsql(final TCustomSqlStatement psql) {
        if (psql.getErrorCount() > 0) {
            this.copyerrormsg(psql);
        }
        for (int k = 0; k < psql.getStatements().size(); ++k) {
            this.findAllSyntaxErrorsInPlsql(psql.getStatements().get(k));
        }
    }

    public TSQLEnv getSqlEnv() {
        return this.sqlEnv;
    }

    public void setOnlyNeedRawParseTree(final boolean onlyNeedRawParseTree) {
        this.onlyNeedRawParseTree = onlyNeedRawParseTree;
    }

    public void setSqlEnv(final TSQLEnv sqlEnv) {
        this.sqlEnv = sqlEnv;
    }

    int doparse() {
        final int ret = this.getrawsqlstatements();
        boolean isPushGloablStack = false;
        TFrame firstFrame = null;
        this.globalContext = new TContext();
        if (this.sqlEnv == null) {
            this.sqlEnv = new TSQLEnv(this.dbVendor) {
                @Override
                public void initSQLEnv() {
                }
            };
        }
        this.globalContext.setSqlEnv(this.sqlEnv);
        if (this.getFrameStack().size() == 0) {
            final TGlobalScope globalScope = new TGlobalScope();
            globalScope.setSqlEnv(this.sqlEnv);
            firstFrame = new TFrame(globalScope);
            firstFrame.pushMeToStack(this.getFrameStack());
            isPushGloablStack = true;
        }
        for (int i = 0; i < this.sqlstatements.size(); ++i) {
            this.sqlstatements.getRawSql(i).setFrameStack(this.frameStack);
            int j = this.sqlstatements.getRawSql(i).parsestatement(null, false, this.onlyNeedRawParseTree);
            TCustomSqlStatement sql0 = null;
            if (this.sqlstatements.get(i).isoracleplsql()) {
                sql0 = this.sqlstatements.get(i);
                this.findAllSyntaxErrorsInPlsql(sql0);
            }
            final boolean doRecover = true;
            if (doRecover && (j != 0 || this.sqlstatements.get(i).getErrorCount() > 0)) {
                if ((this.sqlstatements.get(i).sqlstatementtype == ESqlStatementType.sstcreatetable || (this.sqlstatements.get(i).sqlstatementtype == ESqlStatementType.sstcreateindex && this.dbVendor != EDbVendor.dbvcouchbase)) && !TBaseType.c_createTableStrictParsing) {
                    final TCustomSqlStatement errorSqlStatement = this.sqlstatements.get(i);
                    int nested = 0;
                    boolean isIgnore = false;
                    boolean isFoundIgnoreToken = false;
                    TSourceToken firstIgnoreToken = null;
                    for (int k = 0; k < errorSqlStatement.sourcetokenlist.size(); ++k) {
                        final TSourceToken st = errorSqlStatement.sourcetokenlist.get(k);
                        if (isIgnore) {
                            if (st.issolidtoken() && st.tokencode != 59) {
                                isFoundIgnoreToken = true;
                                if (firstIgnoreToken == null) {
                                    firstIgnoreToken = st;
                                }
                            }
                            if (st.tokencode != 59) {
                                st.tokencode = 273;
                            }
                        } else {
                            if (st.tokencode == 41 && --nested == 0) {
                                boolean isSelect = false;
                                final TSourceToken st2 = st.searchToken(341, 1);
                                if (st2 != null) {
                                    final TSourceToken st3 = st.searchToken(40, 2);
                                    if (st3 != null) {
                                        final TSourceToken st4 = st.searchToken(301, 3);
                                        isSelect = (st4 != null);
                                    }
                                }
                                if (!isSelect) {
                                    isIgnore = true;
                                }
                            }
                            if (st.tokencode == 40 || st.tokencode == 558) {
                                ++nested;
                            }
                        }
                    }
                    if (this.dbVendor == EDbVendor.dbvoracle && firstIgnoreToken != null && !TBaseType.searchOracleTablePros(firstIgnoreToken.toString())) {
                        isFoundIgnoreToken = false;
                    }
                    if (isFoundIgnoreToken) {
                        errorSqlStatement.clearError();
                        j = this.sqlstatements.get(i).parsestatement(null, false);
                    }
                }
                if ((this.sqlstatements.get(i).sqlstatementtype == ESqlStatementType.sstcreatetrigger || this.sqlstatements.get(i).sqlstatementtype == ESqlStatementType.sstcreatefunction || this.sqlstatements.get(i).sqlstatementtype == ESqlStatementType.sstcreateprocedure) && this.dbVendor == EDbVendor.dbvdb2) {
                    final TCustomSqlStatement stmt = this.sqlstatements.get(i);
                    final StringBuffer stmtStr = new StringBuffer(1024);
                    for (int l = 0; l < stmt.sourcetokenlist.size(); ++l) {
                        stmtStr.append(stmt.sourcetokenlist.get(l).astext);
                    }
                    final TGSqlParser lc_sqlparser = new TGSqlParser(EDbVendor.dbvoracle);
                    lc_sqlparser.sqltext = stmtStr.toString();
                    final int iRet = lc_sqlparser.parse();
                    if (iRet == 0) {
                        this.sqlstatements.remove(i);
                        this.sqlstatements.add(i, lc_sqlparser.sqlstatements.get(0));
                        continue;
                    }
                }
            }
            if (j != 0 || this.sqlstatements.get(i).getErrorCount() > 0) {
                this.copyerrormsg(this.sqlstatements.get(i));
                if (this.isEnablePartialParsing() && this.dbVendor == EDbVendor.dbvsybase && this.sqlstatements.get(i).sqlstatementtype == ESqlStatementType.sstmssqlcreateprocedure) {
                    final TMssqlCreateProcedure createProcedure = (TMssqlCreateProcedure) this.sqlstatements.get(i);
                    final StringBuffer storedProcedure = new StringBuffer(1024);
                    boolean ASKeyword = false;
                    for (int m = 0; m < createProcedure.sourcetokenlist.size(); ++m) {
                        if (!ASKeyword && createProcedure.sourcetokenlist.get(m).tokencode == 341) {
                            ASKeyword = true;
                        } else if (ASKeyword) {
                            storedProcedure.append(createProcedure.sourcetokenlist.get(m).astext);
                        }
                    }
                    final TGSqlParser lc_sqlparser2 = new TGSqlParser(this.dbVendor);
                    lc_sqlparser2.sqltext = storedProcedure.toString();
                    lc_sqlparser2.parse();
                    for (int k2 = 0; k2 < lc_sqlparser2.sqlstatements.size(); ++k2) {
                        createProcedure.getBodyStatements().add(lc_sqlparser2.sqlstatements.get(k2));
                    }
                }
            }
        }
        if (isPushGloablStack) {
            firstFrame.popMeFromStack(this.getFrameStack());
        }
        if (TBaseType.ENABLE_RESOLVER && this.getErrorCount() == 0) {
            TBaseType.clearLogs();
            this.collectMetadata();
            this.resolveDatabaseObject();
            this.resolveRelation();
            this.expandStarColumnAndSubQuery();
            this.resolveAttribute();
            this.resolveStarColumn();
            TBaseType.dumpLogs();
        }
        return this.getErrorCount();
    }

    void copyerrormsg(final TCustomSqlStatement sql) {
        for (int i = 0; i < sql.getSyntaxErrors().size(); ++i) {
            this.syntaxErrors.add(new TSyntaxError(sql.getSyntaxErrors().get(i)));
        }
    }

    private static String calculateLicenseKey(final boolean ignoreMachineId) {
        if (TGSqlParser.userName == null) {
            return null;
        }
        if (TGSqlParser.machineId == null) {
            return null;
        }
        byte[] bytesOfMessage = null;
        String licenseStr = "I love sql pretty printer, yeah!" + TGSqlParser.userName.toLowerCase();
        if (!ignoreMachineId) {
            licenseStr += TGSqlParser.machineId.toLowerCase();
        }
        try {
            bytesOfMessage = licenseStr.getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e2) {
            e2.printStackTrace();
        }
        final byte[] digest = md.digest(bytesOfMessage);
        return null;
    }

    private static boolean validateLicense() {
        final int ret = 0;
        return ret == 0;
    }

    private static boolean check_license_time() {
        boolean ret = false;
        final String toDate = "2022-10-19";
        final DateFormat df = DateFormat.getDateInstance(3);
        final Calendar currDtCal = Calendar.getInstance();
        currDtCal.set(11, 0);
        currDtCal.set(12, 0);
        currDtCal.set(13, 0);
        currDtCal.set(14, 0);
        final Date currDt = currDtCal.getTime();
        Date toDt;
        try {
            toDt = df.parse(toDate);
        } catch (ParseException e) {
            toDt = null;
        }
        if (toDt != null) {
            final int results = toDt.compareTo(currDt);
            ret = (results > 0);
        }
        return ret;
    }

    static {
        TGSqlParser.currentDBVendor = EDbVendor.dbvoracle;
        TGSqlParser.machineId = null;
        TGSqlParser.licenseOK = false;
        TGSqlParser.licenseOK = validateLicense();
    }

    enum stored_procedure_status {
        start,
        is_as,
        body,
        bodyend,
        end,
        cursor_declare;
    }

    enum stored_procedure_type {
        function,
        procedure,
        package_spec,
        package_body,
        block_with_begin,
        block_with_declare,
        create_trigger,
        create_library,
        cursor_in_package_spec,
        others;
    }
}
